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