The function of the TimeSeries.BarsSince(...) method is inverted. It should be accumulating the number of past positive bars (as documented), but it's accumulating the number of past negative bars instead. I'm running WL8 Build 49.
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { IndicatorBase ema = new EMA(bars.Close, 10); PlotIndicator(ema); TimeSeries test = bars.Close > ema; PlotTimeSeriesHistogramTwoColor(test,"test result","test"); PlotTimeSeries(TimeSeries.BarsSince(test), "BarsSinceTrue", "BarsSinceTrue", plotStyle: PlotStyle.Histogram); } public override void Execute(BarHistory bars, int idx) { } } }
Rename
Look closely at your screen shot. How many bars has it been SINCE close was greater then the EMA? Isn't that what BarsSince is telling you?
QUOTE:
SINCE close was greater than the EMA?
Look at it again. BarsSince is telling me how many bars Close "has been" less than EMA, not greater. Are you suggesting that there's a semantic ambiguity here? That's not so good. How do we fix that?
What if we renamed it TimeSeries.BarsTrueAccumulator(...) or TimeSeries.BarsTrueCounter(...) instead? Sounds weird, but at least the semantic ambiguity is eliminated.
It’s working correctly. You might be misunderstanding the meaning of the word “since.”
Look at the last value, 8. It means there have been 8 bars SINCE the close has been greater than the ema, which is true.
I don’t see any ambiguity here.
Look at the last value, 8. It means there have been 8 bars SINCE the close has been greater than the ema, which is true.
I don’t see any ambiguity here.
QUOTE:
You might be misunderstanding the meaning of the word “since.”
I wouldn't be the only one. There's a semantic problem with the word "since". You read since as "after-the-fact" (negative thinking) but I read it as "during-the-event" (positive thinking). Is the glass half empty or half full?
I think the function would be less ambiguous if it were renamed TimeSeries.BarsTrueAccumulator(...) or TimeSeries.BarsTrueCounter(...) instead--thinking positively. Ask the other team members what they think. But leaving the name ambiguous is bad design.
What we have now is a False counter, TimeSeries.BarsFalseCounter(...), which is counterintuitive if you're a positive thinker.
Listen, if it's good enough for Metastock it's good enough for WL, they have the exact same function name. I'm sorry you're having difficulty with this but I see no reason to change anything.
Your Response
Post
Edit Post
Login is required