How can i count the number of days this indicator is true?
Rename
You didn't really say what "true" was, but since you wanted to use CrossoverIndValue, I assumed that it mean the number of days since crossing over the high value until the crossing under the low value.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { _rsi = RSI.Series(bars.Close, 14); PlotIndicator(_rsi); double xvalue = 55; _ind1 = new CrossoverIndValue(bars, _rsi, xvalue, 30.00); PlotIndicator(_ind1, WLColor.FromArgb(255,107,139,139), PlotStyle.Line); _barsSince = TimeSeries.BarsSince(_ind1 < 0); PlotTimeSeriesLine(_barsSince, $"Bars Since RSI CrossOver {xvalue}", "BarsSincePane"); SetPaneMinMax(_ind1.PaneTag, -1.2, 1.2); } public override void Execute(BarHistory bars, int idx) { } TimeSeries _barsSince; IndicatorBase _ind1; RSI _rsi; } }
True for me is 1. Thanks for the code but it stays a challeng for me.
The _barsSince series has the value you want. You can get it for any bar in Execute() using _barsSince[idx].
If we're talking about blocks, then you'll need to make a custom indicator for that.
If we're talking about blocks, then you'll need to make a custom indicator for that.
Your Response
Post
Edit Post
Login is required