I was just wondering why this code doesn't work - I have the strategy and the indicator added to a chart. From the Print() statement I can tell the variable is getting set in the indicator, but the plot is just plotting 1's.
public class MyCustomStrategy : Strategy { #region Variables int myValue = 0; #endregion protected override void Initialize(){ CalculateOnBarClose = true; } protected override void OnBarUpdate(){ myValue++; MyCustomIndicator().TestValue = myValue; if(myValue == 10) myValue = 0; } } }
public class MyCustomIndicator : Indicator { #region Variables private int testValue = 0; #endregion protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0")); CalculateOnBarClose = true; } protected override void OnBarUpdate() { Print(testValue); Values[0].Set(testValue); } #region Properties public int TestValue { get { return testValue; } set { testValue = Math.Max(1, value); } }
Comment