I am searching for a WL8 built-in function, where I can calculate the number of bars since the last high, N bars a go (same as the the HHVBars function at Amibroker.
http://www.amibroker.com/guide/afl/hhvbars.html).
http://www.amibroker.com/guide/afl/hhvbars.html).
Rename
You can get the bar of the highest value in the period using the TimeSeries.GetHighestBar() function.
In Execute(), for example, the bars since that high then is:
In Execute(), for example, the bars since that high then is:
CODE:Works for any TimeSeries (or Indicator).
int barsSinceHigh = idx - bars.High.GetHighestBar(idx, 30);
Here's how you could also do it, and I know these TimeSeries Static methods are currently not documented. We're whittling down about 30 documentation to do items and this is one of the last remaining few :)
CODE:
//create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { TimeSeries bsh = TimeSeries.BarsSince(bars.High >= Highest.Series(bars.High, 200)); PlotTimeSeries(bsh, "Bars Since High", "BSH"); }
Documented TimeSeries.BarsSince for B30.
Your Response
Post
Edit Post
Login is required