problem with MACD cross over and new high break outs
- This topic has 5 replies, 3 voices, and was last updated 5 years ago by .
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › problem with MACD cross over and new high break outs
Hi
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.
|
1 2 3 4 5 |
y=highest[20](high)[1] mymacd = macdline[12,26,9] crossup = mymacd crosses over 0 signal=high crosses over y return signal, 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.
I would be grateful if someone could assist.
Thanks
Andrew
Do you want that at least 20 bars have elapsed after the Macd crossover?
Or, if only say 12 bars have elapsed, then you want to retrieve the highest high of those 12 bars instead of 20?
There you go:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
y = highest[20](high)[1] mymacd = macdline[12,26,9] crossup = mymacd crosses over 0 signal = high crosses over y For i = 0 to BarIndex If crossup[i] then Break Endif Endif If i > 20 then //clear signals if more than 20 bars signal = 0 crossup = 0 Endif return signal, crossup |
This should do for 20- bars.
Vonasi’s code is much simpler!
Find exclusive trading pro-tools on