42 SMA 252 SMA Trend Trading Strategy Python Code

30 January 2017, 14:56
Ahmad Hassam
0
209
In this Trend Trading Strategy, we first plot 42 SMA and 252 SMA.

Then we take the difference of 42 SMA with 252 SMA.

We define a threshold value SD also called Regime.

When the 42 SMA -252 SMA difference is greater than SD, we enter a long trade.

When 42 SMA - 252 SMA difference is between +/- SD, we don't enter into a trade.

When 42 SMA - 252 SMA difference is lower than -SD we enter into a short trade.

In this blog post, I have posted the python code that does all the calculations for this trend trading strategy.

In the end I have plotted the equity curve for this trend trading strategy.
Share it with friends: