while developing a non banal custom indicator I met a strange behaviour which I cannot grasp fully. The indicator is intended not to be calculated for the open bar. In other words, it is supposed to calculate position J only when position J+1 appears (= bar J completed)
Below you can find the main loop which should allow for that.
My problem is: price[J] value doesn't get frozen when a new bar appears (rates_total > prev_calculated) but it assumes a avalue which:
a) does not match the value plotted on the chart
b) it gets its final value only 1-2 ticks after the new bar appearance
I wish to understand better the logic beneath in order to code properly
int OnCalculate(const int rates_total,const int prev_calculated,const int begin,const double &price)
// NO NEW BAR -> RETURNS (**))
// FIRST CALL OR NEW BARS -> EXEC CALCULATIONS
jSTART=prev_calculated; // 1st call: starts from bar 0
jSTART=prev_calculated-1; // other calls: starts from the bar before the open bar (see **)
// MAIN CALCULATING CYCLE
for(J=jSTART;J<(rates_total-1);J++) //calculation stops before the open bar
Buf[rates_total-1]=EMPTY_VALUE; //Empties open bar value
Price[J] is the problem, but you don't show it.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code. How To Ask Questions The Smart Way. 2004 Be precise and informative about your problem
We can't see your broken code.
Fix your broken code.
With the information you've provided — we can only guess. And you haven't provided any useful information for that.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.