- ago
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).
0
484
Solved
3 Replies

Reply

Bookmark

Sort
Cone8
 ( 28.25% )
- ago
#1
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:
CODE:
int barsSinceHigh = idx - bars.High.GetHighestBar(idx, 30);
Works for any TimeSeries (or Indicator).
1
Best Answer
Glitch8
 ( 12.08% )
- ago
#2
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"); }
1
- ago
#3
Documented TimeSeries.BarsSince for B30.
0

Reply

Bookmark

Sort