Download MetaTrader 5

iSAR function issue

To add comments, please log in or register
dilipapte
38
dilipapte  

Hi All,

I am using iSAR function in my EA to get the SAR value of last 3 bars. Here is the code I am using.


   SetIndexBuffer(0,indSAR,INDICATOR_DATA);
      
   indsar_handle = iSAR(Symbol(),Period(),0.04,0.2);
   if (indsar_handle > 0)
   {
        ArraySetAsSeries(indSAR, true);
   }

   int sc=CopyBuffer(indsar_handle,0,0,5,indSAR);
      
   s0 = indSAR[0];
   s1 = indSAR[1];
   s2 = indSAR[2];
   

Ideally s0 should have the SAR value of current bar but when I run it, it shows the SAR value of previous bar and not current one. Same is the case with s1 and s2. Please see in the attached screenshot. The s0 at 00:15 is showing the SAR value of 00:00 which is previous bar.

Am I missing something in the code?

dilipapte
38
dilipapte  
Can anyone help here?
To add comments, please log in or register