How to differentiate the angles

I am testing out some crossovers. I find that when the cross over is well visible with price moving down and coming back up, it seems to be better moves than the ones where the lines look almost parallel. how do I differentiate the angles in afl?
for eg. good crossovers.

poor crossovers

I’m not sure but I would try comparing the ROC values of each MA. A high ROC would be a steeper line.


You could use the difference between the slopes of the two moving averages to decide if to take the trade or not. I made an AFL below to do that. It’s an interesting exercise but I doubt that you could make a profit with the idea.

ShortMAPeriod = Optimize("ShortMAPeriod",11,5,40,1);
LongMAPeriod = Optimize("LongMAPeriod",86,40,120,2);
DifferenceNumber = Optimize("DifferenceNumber",0.13,0.01,1,0.01);

ShortMA = MA(C,ShortMAPeriod);
LongMA = MA(C,LongMAPeriod);
Slope1 = LinRegSlope(ShortMA,15);
Slope2 = LinRegSlope(LongMA,15);
Difference = Slope1 - Slope2;
Buy = Cross(ShortMA,LongMA) AND Difference > DifferenceNumber; //buy moving average cross if the slope difference between the two moving averages exceeds a certain amount
Sell = Cross(LongMA,ShortMA);

Plot(slope1, "slope1",colorRed);
Plot(slope2, "slope2",colorAqua);
1 Like