Indicator Buffers and shift- please explain?

 
I am writing an EA that uses the ParabolicSAR value. I want the current PSAR value for the new bar so I am using this call:

// Only operate once on each bar
if(timeprev==Time[0])
{
return(0);
}
timeprev=Time[0];

double SARCurrent = iSAR(NULL, 0, SARStep, SARMaximum, 0);
Print("SARCurrent: " + DoubleToStr(SARCurrent, 8));

Occasionally the chart value for the PSAR and the value the EA logs with the Print statement are not the same. I've been reading through past forum posts and I suspect it's because I'm using shift value 0 from the Indicator Buffer, but I don't really understand. Can't I get the definitive opening value for the PSAR? Wouldn't this be in the first slot of the Indicator Buffer? Forum posts suggest using shift value 1, but I don't understand why this would be better.

I've looked through the forum and documentation for an explaination of how and why the Indicator Buffer is used but haven't found anything very descriptive. Can I please get an explanation or a link to something better than:

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Thank you
 
You get current sar value at bar beginning only. But current value changes if current bar changed.

shift=1 means You get previous value (ie value from previous bar)
 
Thank you for your reply. What shift value will get me the SAR value that is plotted to the chart? Or are you saying the SAR value that is plotted to the chart changes?
 
If You remove check for current bar (if(timeprev==Time[0])) then You get actual changed last SAR value

If You don't want remove this checking then You should get previous (with shift=1) SAR value
 
Thank you Stringo for your quick reply.

What I really want is for the EA to get the same PSAR value that is plotted to the chart. What call can I make so my EA gets the same PSAR value that is shown/drawn/plotted on the attached chart? Or I am not understanding the relationship between an EA and the chart?
 
jskillings, did you ever find a solution to this problem? I'm having the exact same issue.
 

The value of the psar on the chart history will be the value as it was at the close of the bar.

 

I'm using this though, and the SAR did not match my chart even with same settings. I used 1 to avoid trying to use the current bar, since that acts funky.

double SARCurrent = iSAR(NULL, 0, SARStep, SARMaximum, 1);