Hi everyone!
I am very new to coding algos for use in prorealtime and I was wondering if someone could help me with a simple question:
I want to define a requirement to enter trades for example that in order to go long on market the close of all 5 previous bars has to be higher than the previous bar, e.g.
if close[0]>close[1]>close[2]>close[3]>close[4]>close[5] then
buy 1 contract at market
endif
What would be the proper way to code this?
Thanks a lot!
Kind regards
Hi,
for each close higher than previous close 5 times in a row, the long and boring way would be:
if close>close[1] AND close[1]>close[2] AND close[2]>close[3] AND close[3]>close[4] AND close[4]>close[5] then
but you may write it faster with:
if summation[5](close>close[1])=5 then
Moderation points:
– please take into account forum usage highlighted in yellow box at bottom of current page, in this particular case title choice (in order to avoid all ropics in the forum named “help needed”), thanks. I’ll edit your title to replace the “coding help…” with something telling readers about the actual content to decide opening it or not. For example: “coding 5 consecutive higher close” (unless the query itself was misunderstood).
– also moving topic from probuilder forum (indicators) to proorder forum (backtests and automatic strategies sending orders)