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.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue