profitgraphBUY

Download script
profitgraphBUY

This tool is designed to provide traders with a real-time visual summary of their active "Buy" positions within the MetaTrader platform. Rather than requiring you to manually calculate your profits or losses for every open trade, the script automates this process and displays the data clearly in a dedicated window.

How the Logic Works

1. Real-Time Monitoring The script constantly scans your trading account every time the market price moves (each "tick"). It looks specifically for active orders that have been entered as "Buy" positions.

2. Automated Calculation For every open Buy order found, the script performs a quick mathematical calculation behind the scenes. It compares the current live market price against the price at which you originally opened the trade.

3. Converting Price to Points Instead of showing you raw price differences (which can be confusing in some currency pairs), the logic converts these differences into "points." This allows you to see exactly how many pips or points your position is currently up or down from your entry point.

4. Organized Visual Feedback The script is configured with seven distinct data slots (buffers). As it identifies your Buy orders, it maps them sequentially to these slots.

  • If you have one open trade, it shows the status for that specific trade.
  • If you have multiple trades open simultaneously, it will list them one by one.
  • Each line on the indicator serves as a visual tracker for an individual position, allowing you to monitor the performance of up to seven different Buy orders at a glance in a single consolidated view.

Summary for the User

Essentially, this is a Live Profit/Loss Tracker. It simplifies your dashboard by pulling all your open Buy positions into one window and showing you exactly how far each trade has moved in your favor (or against you) in points, updating instantly as the market fluctuates.

Orders Execution
Checks for the total of open orders
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
profitgraphBUY
//+-----------+
//| LSMA      |
//+-----------+
#property  copyright "Copyright 2005 Ron Thompson"
#property  link      "http://www.forexmt4.com/"

//---- indicator settings
#property  indicator_separate_window

#property indicator_buffers   7

#property indicator_color1  LawnGreen
#property indicator_width1  2
#property indicator_color2  LawnGreen
#property indicator_width2  2
#property indicator_color3  LawnGreen
#property indicator_width3  2
#property indicator_color4  LawnGreen
#property indicator_width4  2
#property indicator_color5  LawnGreen
#property indicator_width5  2
#property indicator_color6  LawnGreen
#property indicator_width6  2
#property indicator_color7  LawnGreen
#property indicator_width7  2


//---- buffers
double B1[];  //Yellow
double B2[];  //Green
double B3[];  //Red
double B4[];  //Blue
double B5[];  //Aqua
double B6[];  //LawnGreen
double B7[];  //Yellow



//+-----------+
//| Init      |
//+-----------+
int init()
  {
   // 233 up arrow
   // 234 down arrow
   // 158 little dot
   // 159 big dot
   // 168 open square
   // 120 box with X

   SetIndexBuffer(0,B1);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(1,B2);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(2,B3);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(3,B4);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(4,B5);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(5,B6);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2);

   SetIndexBuffer(6,B7);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 2);



   Print("Init complete");
  }

//+-----------+
//| DE-Init   |
//+-----------+
int deinit()
  {
   Print("DE-Init complete");
  }


//+-----------+
//| Each Tick |
//+-----------+
int start()
  {   
   int ptr=0;
   
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      OrderSelect(i, SELECT_BY_POS);
      if ( OrderType()== OP_BUY) ptr++;
           
      if(ptr==1) {B1[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(0,OrderSymbol());}
      if(ptr==2) {B2[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(1,OrderSymbol());}
      if(ptr==3) {B3[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(2,OrderSymbol());}
      if(ptr==4) {B4[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(3,OrderSymbol());}
      if(ptr==5) {B5[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(4,OrderSymbol());}
      if(ptr==6) {B6[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(5,OrderSymbol());}
      if(ptr==7) {B7[0]=(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT); SetIndexLabel(6,OrderSymbol());}
      
     }
      
   }//start



Comments