I want to reference an exposed variable (not a DataSeries) of a custom indicator in a real time strategy (COBC = false) at the close of each bar (FirstTickOfBar). Since it's a variable and not a DataSeries that is referenced, the indicator output can't be shifted with a bars ago index of [1]. How would I correctly reference this variable in the strategy to return an output value for the close of each bar? Should the current or the previous variable value be exposed?
When a strategy calls an indicator at FirstTickOfBar, will the referenced indicator output be returned before or after the OnBarUpdate() method of the indicator is processed for that first tick? Does the Update() method in the "getter" affect this behaviour somehow?
Best Regards,
Poseidon
Indicator:
// Variables private double exposedVariable; protected override void OnBarUpdate() { exposedVariable = xyz; } //Properties [Browsable(false)] [XmlIgnore()] public double ExposedVariable { get { Update(); // Ensure our exposed variable is up-to-date. return exposedVariable; } }
protected override void Initialize() { CalculateOnBarClose = false; } protected override void OnBarUpdate() { if (FirstTickOfBar && Position.MarketPosition == MarketPosition.Flat) { if ( myIndicator.exposedVariable > Close[0] ); EnterLong("long entry"); } }
Comment