MT5 Tester object moves itself on one side

 

hello 

i have been creating simple divergency strategy to my EA that will involve drawing the divergence lines to the main chart and to the indicator window ...using this code

void divergence(){
   CopyBuffer(rsi_handle,0,0,rsi_period,rsi_array);
//---
   double A=0;
   double B=0;
   datetime TimeA=0;
   datetime TimeB=0;
   int obj=0;
   int obj2=0;
//---
   for (int i=2; i<rsi_period; i++){
     A=(double)iOpen(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_OPEN,rsi_period,1));
     B=(double)iOpen(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_CLOSE,rsi_period,1));
     TimeA=iTime(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_OPEN,rsi_period,1));
     TimeB=iTime(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_CLOSE,rsi_period,1)); 
      {
      if (A<B && rsi_array[1]<rsi_array[rsi_period-x_distance])
        { 
           TrendCreate(0,"TrendLine"+string(obj++),0,TimeA,A,TimeB,B);
           TrendCreate(0,"TrendLine2"+string(obj2++),1,TimeA,rsi_array[rsi_period-x_distance],TimeB,rsi_array[1]);  
        } 
      if (B>A && rsi_array[1]>rsi_array[rsi_period-x_distance])
        {
          TrendCreate(0,"TrendLine"+string(obj++),0,TimeA,A,TimeB,B);
          TrendCreate(0,"TrendLine2"+string(obj2++),1,TimeA,rsi_array[rsi_period-x_distance],TimeB,rsi_array[1]);  
        } 
      }
   }  
}
//---
bool TrendCreate(const long            chart_ID=0,        
                 const string          name="TrendLine",  
                 const int             sub_window=0,      
                 datetime              time1=0,           
                 double                price1=0,          
                 datetime              time2=0,            
                 double                price2=0,          
                 const color           clr=clrRed,       
                 const ENUM_LINE_STYLE style=STYLE_DASH, 
                 const int             width=2,           
                 const bool            back=false,        
                 const bool            selection=false,   
                 const bool            ray_left=false,   
                 const bool            ray_right=false,   
                 const bool            hidden=true,        
                 const long            z_order=0)          
  {  
   ResetLastError();  
   if(!ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,time1,price1,time2,price2)) 
     { 
      Print(__FUNCTION__, 
            ": failed to create a trend line! Error code = ",GetLastError()); 
      return(false); 
     }  
//---
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);  
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);  
   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_LEFT,ray_left);  
   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);  
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);  
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 
//--- successful execution 
   return(true); 
  } 

it works perfect on demo Account ..My Aim is to create small trendlines objects that will demostrate divergencies

divergence demo


but it doesn't on the Strategy tester where it just opens one object and then keeps on modifying its end by adding values  while the other side keeps sticking to the  first primary point

(see image)


 
Omega J Msigwa:

hello 

i have been creating simple divergency strategy to my EA that will involve drawing the divergence lines to the main chart and to the indicator window ...using this code

it works perfect on demo Account ..My Aim is to create small trendlines objects that will demostrate divergencies


but it doesn't on the Strategy tester where it just opens one object and then keeps on modifying its end by adding values  while the other side keeps sticking to the  first primary point

(see image)


i just realized that it does the same on demo account also

Reason: