Download MetaTrader 5

SL/TP markers on backtest graph

To add comments, please log in or register
graziani
1968
graziani 2013.07.08 01:14 

i miss those SL/TP markers on backtest graphs, anybody has a code how to draw it?

Tried like this, but nothing happens, although it works in simple loop:

   if (OrderSend(request, result) == true)
   {  // if(result.retcode==TRADE_RETCODE_DONE)

      if (request.tp > 0)
      {  string arrow = "TP" + TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES);
         ObjectCreate(0, arrow, OBJ_ARROW_LEFT_PRICE, 0, TimeCurrent(), request.tp);
         ObjectSetInteger(0, arrow, OBJPROP_COLOR, clrGreen);
         ObjectSetInteger(0, arrow, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSetInteger(0, arrow, OBJPROP_WIDTH, 1);
         ObjectSetInteger(0, arrow, OBJPROP_SELECTABLE, true);
      }

      if (request.sl > 0)
      {  string arrow = "SL" + TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES);
         ObjectCreate(0, arrow, OBJ_ARROW_LEFT_PRICE, 0, TimeCurrent(), request.sl);
         ObjectSetInteger(0, arrow, OBJPROP_COLOR, clrRed);
         ObjectSetInteger(0, arrow, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSetInteger(0, arrow, OBJPROP_WIDTH, 1);
         ObjectSetInteger(0, arrow, OBJPROP_SELECTABLE, true);
      }

      if (dbgInfo == true) Print("Ticket = ", result.deal);
      return ((int)result.deal);
   }

 

 

graziani
1968
graziani 2013.07.08 08:39  

OK, it works with visualization ON, and on normal graph.

So the problem is probably that graph isn't created in moment of creating object. Solutions? 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
Alain Verleyen
Moderator
31133
Alain Verleyen 2013.07.08 09:10  
graziani:

OK, it works with visualization ON, and on normal graph.

So the problem is probably that graph isn't created in moment of creating object. Solutions? 

Yes, read the documentation
To add comments, please log in or register