I have seen that the market will often test support/resistance levels 3 times before proceeding to the next level, I can’t work out the best way to keep track of the number of crosses (closes above/below?) in code, please help.
Regards
Steve
What kind of support / resistance do you want to test?
Test if price has crossed up or down a resistance/support price and count it by incrementing a variable.
This is an example with a rebound on a moving average:
mm = average[20](close)
IF low < mm AND close > mm THEN
count = count + 1
ENDIF
IF count = 3 THEN
BUY 1 LOT AT MARKET
// RESET COUNT
count = 0
ENDIF
Thanks Nicolas, that looks really interesting.
It could be any support/resistance level, such as a pivot, a moving average, a high/low, a round number, I think your code will work for them all, just modify the mm entry.
Regards
Steve