MACD turnaround point

Hi all,

I would like to screen for stocks which recently had a turnaround in the MACD signal (see arrow in attachment).

To do this I need to create a formula which gives me the day (bars ago) in last 15 trading days with the lowest MACDD signal value, but not the value itself.

To get the lowest value itself I would simply use LoopMin

LoopMin("MACDD(12,26,1,CTR)",15)

But what I am after is the CTR when this lowest value occurs, which fulfills the following condition:

MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR+1) AND MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR-1)

Does anybody know how I can implement this in a loop and get the CTR as answer, like
Eval(condition with loop, CTR,0)

Best regards,
Florian


:sunglasses: I think I cracked the nut…

LoopMax("Eval(MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR+1) AND MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR-1),CTR,0)",15,1)

For the screener I use…

Universe(SP500)
SetVar(@minMACD,LoopMin("MACDD(12,26,1,CTR)",15)) 
SetVar(@turnbar,LoopMax("Eval(MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR+1) AND MACDD(12,26,1,CTR)<MACDD(12,26,1,CTR-1),CTR,0)",15,1)) 
@turnbar<7 AND @turnbar>2 AND @minMACD<0 //Turnaround between 3-6 bars ago with negative MACD value at that bar

For the S&P500 this returns 28 stocks as of today.

These criteria define the universe for a trading strategy. Next one can create some buy and sell signals (as shown for WDC in the fundamental chart below) and finally implement it into a model…