It’s the number of previous bars you want to test that makes a high as the all-time high or not.
If you run your code on a 1-minute TF, even with 1M bars (v11 will allow this huge number), you’ll get the highest high of roughly the last 3.5 years, while on a MONTHLY TF that would go back way more, thus making that high as a very likely all-time high, since that instruments was first recorded as computer data, of course.
Anyway the code would simply be:
1
Buy1contractathighest[n](high)Stop
“n” is the lookback number of bars. Bear in mind that ProOrder won’t allow 1M, neither 100k, as “n”, though I don’t know exactly. I know that max. preloaded bars can be 10,000.
You could suggest supporting a new function, beyond HIGHEST and LOWEST:
ALLTIME(high/low)
to get the highest/lowest value since the very beginning, no matter what TF.
You could also calculate in real time the new “all time high”, if you don’t want to use a predetermined period.
1
2
3
4
5
hh=max(high,hh)
ifnotonmarketandclosecrosses overhh[1]then
buyatmarket
endif
Of course the all time high will depend of the history loaded. In the above example, you will also have to exit the order once in a while (depending of your conditions, e.g. takeprofit, stoploss, trailing stop, ..) to be able to re-enter in the market when a new breakout occurs.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.