- ago
Apparently, the greater than ">" operator for TimeSeries (see below) returns incorrect results when comparison values are close to boarder line cases; e.g. 93.5 and 94.5. I'm running WL8 Build 163.
CODE:
TimeSeries smaHigh = sma > 95.0; //this operation is inaccurate

Examples are highlighted in magenta in the screenshot below.


CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript3 {    public class MyStrategy : UserStrategyBase    {       IndicatorBase stochK;       TimeSeries sma;       public override void Initialize(BarHistory bars)       {          stochK = StochK.Series(bars,200);          PlotIndicator(stochK, paneTag: stochK.Description);          sma = SMA.Series(stochK,5);          TimeSeries smaHigh = sma > 95.0; //this operation is inaccurate          PlotTimeSeriesHistogramTwoColor(smaHigh,smaHigh.Description,smaHigh.Description);          for (int bar = sma.FirstValidIndex; bar < sma.Count; bar++)             SetBackgroundColor(bars, bar, smaHigh[bar]>0.0 ? WLColor.Orange : WLColor.Transparent, stochK.Description);       }       public override void Execute(BarHistory bars, int idx) { }    } }
0
76
2 Replies

Reply

Bookmark

Sort
Cone8
- ago
#1
Definitely a bug - but yours.
If you plot the series you're comparing (instead of stochK), it will work out just fine. Try this:

CODE:
PlotTimeSeriesLine(sma, "SMA", paneTag: stochK.Description);
0
- ago
#2
Thanks for pointing that out.
1

Reply

Bookmark

Sort