S&P 500 mean reverting strategy

Category: Strategies By: Francesco78 Created: September 13, 2017, 10:53 AM
September 13, 2017, 10:53 AM
Strategies
18 Comments

Dear all,

pls enjoy this little code which gives very nice results on S&P 500.

There are only 2 variables optimized (the bollinger bands and the moving average periods) , can work with several underlying.

Best regards

Francesco

// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated

//optimized parameters
bbperiod = 30
averageperiod = 180

bollup = BollingerUp[bbperiod](close)
bolldown = BollingerDown[bbperiod](close)
cl = (close >= bollup)
cl = cl AND (open >= bollup)
cs = (close <= bolldown)
cs = cs AND (open <= bolldown)

IF cs THEN
 buy 5 PERPOINT AT MARKET
ENDIF

if cl then
 sellshort 5 perpoint at market
endif

// Conditions to exit short positions
aver = Average[averageperiod](close)
c1 = (close CROSSES under aver)
c2 = (close CROSSES over aver)
IF c1 and longonmarket THEN
 sell AT MARKET
ENDIF

if c2 and shortonmarket then
 exitshort at market
endif

Download
Filename: wf_Stat.png
Downloads: 309
Download
Filename: SP_stat-1.png
Downloads: 328
Download
Filename: SP_stat.png
Downloads: 546
Download
Filename: meanreverting_boll_SP.itf
Downloads: 806
Francesco78 Master
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Logo Logo
Loading...