Using 200 ema up or down from previous day not price crossing

I want to use the 200 ema itself going up or down as the actual signal to buy or sell, not the price crossing above/below the 200 ema, combined with the MACD Line (12-day EMA - 26-day EMA) crossing above or below the zero line. I have zero programming knowledge and would really appreciate a formula if this can be done. TU.

hello there
i dont think what you asking to be so difficult for you to write this code.
and for that reason i comment for you slow-slow to start to learn about the cross function

https://forum.amibroker.com/search?q=CROSS

How to Use “Cross”, When One Thing Crosses Another

2 Likes

@tj6575 I agree with @PanoS that learning the CROSS function is essential (especially for your MACD condition) but I interpreted your question about the moving average differently.

First, review the resources in this thread to get started on learning afl.

Then with regards to the moving average changing from a dropping ema to a rising ema, you could try something like this

TheMA = EMA(C, 200);

// the moving average was falling and then turns UP
maUP = TheMA > Ref(TheMA, -1) AND Ref(TheMA, -1) <= Ref(TheMA, -2);

// the moving average was rising and then turns DOWN
maDOWN = TheMA < Ref(TheMA, -1) AND Ref(TheMA, -1) >= Ref(TheMA, -2);

image
image

5 Likes