When ensuring an Indicator is updated and suitable for use in a Strategy please advise if the below simple code is inadvisable and why.
public class MyStrategy: Strategy { private MyIndicator _myIndicator; protected override void OnStateChange() { if (State == State.Configure) { _myIndicator = MyIndicator(); } } protected override void OnBarUpdate() { _myIndicator.Update(); //etc } }
- UserGuide (Update()),
- Reference Sample (Indicator: Exposing indicator values that are not plots), and
- @suprsnipes post (Using exposed variable from indicator within strategy)
Would the below code work to ensure MyIndicator is updated?
public class MyIndicator: Indicator { private boolean _isUpdated; protected override void OnStateChange() { } protected override void OnBarUpdate() { _isUpdated = true; // other code } public boolean IsUpdated { get { Update(); return _isUpdated } } }
Shannon
Comment