I am trying to expose another indicators value by way of a public property.
Starting w/ NT's ATR Trailing Stop script from an S&C article, I tried to add a public prperty to tell me if bar[0] was the bar that hit the trailing stop, and the stops have now flipped...
either they were above the bars, and now are under, or vice versa.
I added some print lines, and it will print the correct bars time, and the expected true to the output window when the indicator is applied to a chart.
But when I try to access the property from another script, like a strategy, the property always returns false.
Why is it True in the indicator and false on the same bar as a public property?
Script exerpt follows entire ATR stops with public property attached.
else if (Close[0] > Value[1]) { trail = Close[0] - loss; //This bar caused StopLoss to flip from above bars to below bars, so set flippedLong to true, flippedShort to false flippedLong = true; flippedShort = false; DrawArrowDown(CurrentBar.ToString(), false, 1, Value[1], Color.Orange); Print(Time[0].ToString()); //Public Property FlippedLong will print showing it is set to true on this bar, but when this property is accessed from another script, it always //returns false WHY? Print(FlippedLong); } else { trail = Close[0] + loss; flippedShort = true; flippedLong = false; DrawArrowUp(CurrentBar.ToString(), false, 1, Value[1], Color.Orange); Print(Time[0].ToString()); //Public Property FlippedShort will print showing it is set to true on this bar, but when this property is accessed from another script, it always //returns false WHY? Print(FlippedShort); } Value.Set(trail); } #region Properties [Description("ATR period")] [Category("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } [Description("ATR multiplication")] [Category("Parameters")] public double Multi { get { return multi; } set { multi = Math.Max(0, value); } } [Description("Flipped Bullish This Bar")] public bool FlippedLong { get { return flippedLong; } //set { } } [Description("Flipped Bearish This Bar")] public bool FlippedShort { get { return flippedShort; } //set { } }
Comment