Problem adding text over bars with criteria in strategy

 

Hi,

Trying to add text to on the bar when criteria met and buy order processed. On the first order it is adding Sample Text on the chart, but for further order not adding. So text is added only one and first order. I want to display text for each time that buy order opened. Orders opening without problem repeatly, but adding text function not repeating. Already trying to do it for long time but couldnt solve the problem. I am newbie, and may be it is a very simple question. If somebody who understand where the problem is will be very glad.

//-----------------------------------------------------------------
// Bar checks
//-----------------------------------------------------------------
 if(iOpen(NULL,0,1)<iClose(NULL,0,1)) int BarOneUp=1;
 if(iOpen(NULL,0,1)>iClose(NULL,0,1)) int BarOneDown=1;

 if(iOpen(NULL,0,2)<iClose(NULL,0,2)) int BarTwoUp=1;
 if(iOpen(NULL,0,2)>iClose(NULL,0,2)) int BarTwoDown=1;

 if(iOpen(NULL,0,3)<iClose(NULL,0,3)) int BarThreeUp=1;
 if(iOpen(NULL,0,3)>iClose(NULL,0,3)) int BarThreeDown=1;
 
 
//-----------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------
// Opening criteria
//-----------------------------------------------------------------------------------------------------

// Open buy direct
if(BarOneDown==1&&BarTwoDown==1&&BarThreeDown==1&&halt1!=1){
 int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,slb,tpb,"Candle bug buy order",MagicNumber1,0,Blue);

 if(ReverseClose==true)closesell=1;
            if (Display_3Bars == true)  {
            ObjectCreate("AddText", OBJ_TEXT, 0, Time[1], High[1]);
            ObjectSetText("AddText", "SampleText", 18, "Times New Roman", Yellow);            
         }
 }

// Open buy by continuation
if(BarOneDown==1&&BarTwoDown==1&&BarThreeDown==1&&halt1!=1&&Continuation==true){
  openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,slb,tpb,"Candle bug buy continuation order",MagicNumber1,0,Blue);
  if(ReverseClose==true)closesell=1;
           if (Display_3Bars == true)  {
            ObjectCreate("AddText"+TimeToStr(Time[1]), OBJ_TEXT, 0, Time[1], High[1]);
            ObjectSetText("AddText"+TimeToStr(Time[1]), "SampleText", 18, "Times New Roman", Yellow);            
         }
 }


 
ObjectCreate("AddText", OBJ_TEXT, 0, Time[1], High[1]);

You cannot create additional objects with the same name. Use Time or something to give it a unique name.

ObjectCreate("AddText"+TimeToStr(Time[1]), OBJ_TEXT, 0, Time[1], High[1]);
 
Changed like that but still same. Only 1 time displaying text.
 
santaferes:
Changed like that but still same. Only 1 time displaying text.
I see that you have changed the 2nd ObjectCreate code, but the 1st is unchanged
 
Yes now done!! Thank you very much Moderator.. Great and very fast help.. I appreciate you!!
Reason: