I have some indicators with CPU intense calculations (array sort etc) that only need to be recalculated on bar close, so I do this FirstTickOfBar using "if (FirstTickOfBar)". But I have now encountered an unexpected situation when referencing an output series of another indicator FirstTickOfBar in real time. According to my print statments it seems as the calling indicator in real time (COBC = false) is updated before its referenced indicators have called the OnBarUpdate() method on the first tick of a bar. The situation only occurs if you call the refernced indicator series one or more bars ago ( Indicator().outputSeries[1] ) but not if you call the indicator on the current bar ( Indicator().outputSeries[0] ). Calling Update() in the getter doesn't solve this problem. How do I make the referenced indicator update on FirstTickofBar before it is called by the caller?
I have attched a simple as possible example with a caller and a callee for you to reproduce. These indicators generated the following print statments in Market reaplay with COBC = false.
CALLER: ************************************************************************ Bar Close Time: 2011-10-03 08:10:00 CurrentBar: 25 [COLOR=Red]TickCount: 1[/COLOR] CalculateOnBarClose: False ************************************************************************ [COLOR=Red]TestCalleeFTOB().BarNumber[x]: 0 squareOfBarNumber[x]: 0[/COLOR] CALLEE: (The referenced indicator) ************************************************************************ Bar Close Time: 2011-10-03 08:10:00 CurrentBar: 25 TickCount: 1 CalculateOnBarClose: False ************************************************************************ barNumber[x]: 24 CALLER: ************************************************************************ Bar Close Time: 2011-10-03 08:10:00 CurrentBar: 25 TickCount: 2 CalculateOnBarClose: False ************************************************************************ CALLEE: (The referenced indicator) ************************************************************************ Bar Close Time: 2011-10-03 08:10:00 CurrentBar: 25 TickCount: 2 CalculateOnBarClose: False ************************************************************************ barNumber[x]: 24 TestCalleeFTOB().BarNumber[x]: 24 squareOfBarNumber[x]: 576
poseidon_sthlm
Comment