Past Candle Question

 
The following code will show the Open, Close, High and Low for the 26th candle, back form the current.  How can I draw an arrow, to mark this candle?
         double xPH =  iHigh(NULL,PERIOD_M5,26);  //  High[1];
         double xPL =  iLow(NULL,PERIOD_M5,26);   //  Low[1];
         double xPO =  iOpen(NULL,PERIOD_M5,26);  //  High[1];
         double xPC =  iClose(NULL,PERIOD_M5,26);   //  Low[1];      
         double xBody =  (( xPO - xPC )*10000);
        

 
    
   
        Alert("xPH =  ",DoubleToStr(xPH,Digits),"   xPL =  ",DoubleToStr(xPL,Digits),"   xPO =  ",DoubleToStr(xPO,Digits),"   xPC =  ",DoubleToStr(xPC,Digits),"   xBody =  ",xBody);
        
      
     


     ObjectCreate("UpArrowBz", OBJ_ARROW, 0, Time[26],0);         
     ObjectSet("UpArrowBz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
     ObjectSet("UpArrowBz", OBJPROP_COLOR,White);      

So far the arrow is drawing on the twelfth candle.

Thanks!

 

I'm surprised that you can see the arrow if its price is 0. Are you sure that the arrow you can see is the one generated by this code?

Delete the arrow and run the code again.

You are getting values from the M5 chart, so do you need to get the time value from the M5 chart as well? You will not calculate the correct candle if the current chart is not M5

 
 
 
Yellowbeard:
The following code will show the Open, Close, High and Low for the 26th candle, back form the current.  How can I draw an arrow, to mark this candle?

So far the arrow is drawing on the twelfth candle.

Thanks!

The code you have shown is not drawing that arrow at that position . . . you have a price of zero in your code . . .

ObjectCreate("UpArrowBz", OBJ_ARROW, 0, Time[26],   0  );

 . . .  yet the arrow is at a price around 0.946

 

If you already have the arrow created by some other code you cannot ObjectCreate()  it again, so check if the Object exists using ObjectFind()  if it does use ObjectSet() to move it to the correct bar. 

 
RaptorUK: check if the Object exists using ObjectFind()  if it does use ObjectSet() to move it to the correct bar.
Or (like my code) try to move the object and that fails, create it
 

O.K.  Here's the code that works.  This finds O,C,H,&L of the 26th candle from the current, including the current (0).  It places an arrow on the candle and shows the size of the body.

         X = 25;

         
         double xPH =  iHigh(NULL,PERIOD_M5,X);  //  High[1];
         double xPL =  iLow(NULL,PERIOD_M5,X);   //  Low[1];
         double xPO =  iOpen(NULL,PERIOD_M5,X);  //  High[1];
         double xPC =  iClose(NULL,PERIOD_M5,X);   //  Low[1];   

   
        
        
        if( xPO < xPC )
        {double xBody =  (( xPC - xPO )*10000);}
        
        if( xPO > xPC )
        { xBody =  (( xPO - xPC )*10000);}

   
        Alert("xPH =  ",DoubleToStr(xPH,Digits),"   xPL =  ",DoubleToStr(xPL,Digits),"   xPO =  ",DoubleToStr(xPO,Digits),"   xPC =  ",DoubleToStr(xPC,Digits),"   xBody =  ",xBody);

        
      
     ObjectCreate("UpArrowBz", OBJ_ARROW, 0, Time[X],xPO);         
     ObjectSet("UpArrowBz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
     ObjectSet("UpArrowBz", OBJPROP_COLOR,White);  

  Now, I just need to figure out how to find the values of ExtSpanA and ExtSpanB, of a Ichimoku indicator, at that candle.