Custom Indicator is showing different results for same time frame when switched between M1 and M5

 

Hi,

i created a simple indicator based on Stoch, but it gives me different results for the same time frame when being switched to M5 or M15.

has anyone got same problem?

 many thanks

just 

 
If you mean you get different results when switch to another TF and back, then your code is broken.
 

Hi

thank you for your reply.

TF is M1 as default. 

the change is happening just to the new bars after last switch back to M1 !!

 somehow, bar 1 is being calculated wrongly when shift happen from bar 0 to bar 1.

even, i recalculate the last bar but making mess. 

many thanks

just 

 
Asked and answered.
WHRoeder: then your code is broken.
 

hi,

thank you for you reply.

i found out the reason. it was a basic mistake.

 

int IndicatorCounted( )
The function returns the amount of bars not changed after the indicator had been launched last. The most calculated bars do not need any recalculation. In most cases, same count of index values do not need for recalculation. The function is used to optimize calculating.

Note: The latest bar is not considered to be calculated and, in the most cases, it is necessary to recalculate only this bar. However, there occur some boundary cases where custom indicator is called from the expert at the first tick of the new bar. It is possible that the last tick of the previous bar had not been processed (because the last-but-one tick was being processed when this last tick came), the custom indicator was not called and it was not calculated because of this. To avoid indicator calculation errors in such situations, the IndicatorCounted() function returns the count of bars minus one. 

 

thanks

just 

Reason: