ViewOrdersProfit

ViewOrdersProfit

This script is designed to provide a real-time visual summary of your active trading positions directly on your market chart. It functions as a dynamic calculator that aggregates the financial status of your open trades and displays it in a clean, readable text format.

How it Works

The core logic of this tool involves scanning your entire trading account every time the platform updates. It performs the following steps automatically:

1. Active Order Scanning The script systematically looks through all currently open positions. It ignores pending orders (orders waiting to be triggered) and focuses exclusively on active "Buy" and "Sell" trades.

2. Dynamic Profit Scaling One of the key features of this logic is its ability to normalize profit calculations based on a specific reference size. The script uses a user-defined "Lot" setting to act as a baseline.

  • If your actual trade size is different from this base value, the script mathematically adjusts the profit figure.
  • This allows you to see what your profit would look like if all your trades were scaled to a standard unit, making it easier to compare the performance of various positions regardless of their individual sizes.

3. Information Gathering For every active trade found, the script collects three vital pieces of information:

  • The unique identification number (Ticket) of the trade.
  • The specific currency pair or asset being traded (Symbol).
  • The current profit/loss value, adjusted by the scaling logic mentioned above.

4. Real-Time Visual Display Finally, the script compiles all this data into a continuous text block. Instead of you having to click through different tabs or windows to check your P&L, it prints this summary directly onto your main trading screen. It lists each trade on a new line, providing an instant snapshot of your current market exposure and cumulative performance.

Orders Execution
Checks for the total of open orders
12 Views
0 Downloads
0 Favorites
ViewOrdersProfit
#property indicator_chart_window
extern double Lot = 0.1;
int start()
  {
   int i,l1,l2;
   double profit;
   string st;   
   st="Ïðèáûëü/óáûòîê ïî îòêðûòûì îðäåðàì èç ðàñ÷åòà çà "+DoubleToStr(Lot,1)+" ëîò:\n";
   for(i=0;i<OrdersTotal();i++)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderType()==OP_BUY || OrderType()==OP_SELL)
      {
         st=st+OrderTicket()+" - "+OrderSymbol()+" - ";
         if(OrderType()==OP_BUY) st=st+"BUY = "; else st=st+"SELL = ";
         l1=Lot/0.1; l2=OrderLots()/0.1;
         profit=OrderProfit()/l2*l1;
         st=st+DoubleToStr(profit,2)+"\n";
      }
   }
   Comment(st);
   return(0);
  }


Comments