I’ve been trying to write an indicator to highlight breakouts above 20 period highs but only those that have happened within 20 days after the cross of the MACD (highlight the start of a new trend). I can code the individual parameters but can’t work out how to combine them together.
Breakouts for 20 day high after MACD cross
1
2
3
4
5
y=highest[20](high)[1]
mymacd=macdline[12,26,9]
crossup=mymacdcrosses over0
signal=highcrosses overy
returnsignal,crossup
I was thinking that a loop looking back over the prior 20 days after each new 20 day high to check for a MACD cross would be a potential solution but I can’t work out how to code it.
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.Ok