A simple calculation and plotting of the slope of a Moving Average. You'll be amazed looking at how accurate it is signaling early entries and exits from trend follower positions, just by applying some basic TA to it (support, resistance, trend lines). Have a look:
In the settings, you can choose to use it on EMA on SMA, and the length of the MA involved.
I recommend using it on a medium-long sampling MA, to minimize noise.
Hi Luka, on the 2 days when the green circle indicated a trendline break, the slope of the 130-day EMA (teal colour line) had not yet changed direction. Can you please explain the logic from line 6 onward in your code? Thank you.