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.

2 Likes

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.

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

//Calculations
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);
Short=Cover=0;

//Charting
Plot(slope1, "slope1",colorRed);
Plot(slope2, "slope2",colorAqua);
Plot(Difference,"Difference",colorYellow);
1 Like