MACD crossover not MACD above MACD signal line

Sir I have studied all MACD realtef algos and applied but the problem is the the algos gives signals when macd is above signal line. Mostly irrelevant signals cause crossover and share price increase already happened .i need the exact moment when crossover is happening…i applied the macd crossover algo from tradescript but it is generating error. Pls sir provide me MACD crossover algo.

hElLO tRaDeR,

The MACD crossover script on the tradescript guide and as stated on some MACD related answers on this forum is a bit misleading.

INSTEAD USE THIS FOR THE CORRECT CROSSOVER BACK TESTING:

POSITIVE MACD CROSSOVER: ( MACD LINE CROSS TO UP ABOVE THE SIGNAL LINE)

SET A = MACD(13, 26, 9, EXPONENTIAL)
SET B = MACDSIGNAL(13, 26, 9, EXPONENTIAL)
CROSSOVER(A,B) = TRUE

NEGATIVE MACD CROSSOVER: (MACD LINE CROSS TO DOWN BELOW THE SIGNAL LINE)

SET A = MACD(13, 26, 9, EXPONENTIAL)
SET B = MACDSIGNAL(13, 26, 9, EXPONENTIAL)
CROSSOVER(B,A) = TRUE

ALSO FINDING CROSSOVER THE LONG WAY ROUND:

MACD(13, 26, 9, EXPONENTIAL) > MACDSIGNAL(13, 26, 9, EXPONENTIAL) AND 
REF(MACD(13, 26, 9, EXPONENTIAL),1) < REF(MACDSIGNAL(13, 26, 9, EXPONENTIAL),1)

DeAr SiR
With all regards this scripts is also not working keeps saying script generated an error. .m sweating here thinking that i understood only one concept of all…n what if there is no script to trigger the MACD crossover for me.
Help me out…kindly provide a script that works merry for me…
Regards
worried tRaDeR ( P.S i worked on the spacing also between the algos so thts not an issue)

Updated the answer with “ALSO FINDING CROSSOVER THE LONG WAY ROUND:” technique
ALSO USE A LONG EXIT CODE WHEN BACKTESTING YOUR STRATEGY Eg LONG EXIT: CLOSE < OPEN

not working, generating error

Please try the second method in the main answer.