I sometimes try to come back to trading system, in order to give more efficiency to my buy & hold strategy.
Starting from this interesting page http://bettersystemtrader.com/bollinger-band-trading-strategy/, I wrote the following code
//@version=4
// strategy “bollinger-band-trading-strategy” taken from bettersystemtrader.com
// Entry: Buy on the Open the day after a stock closes above the top Bollinger Band
// Exit: Exit on the Open the day after a stock closes below the lower Bollinger Band
// In Nicks book, he uses 100 period Bollinger Bands so we’ll do the same. The upper Bollinger Band will be 3 deviations from the central line, the lower Bollinger Band will be 1 deviation below the central line.
// money management added
strategy(title = “Bollinger Blast Buy Unholy Grail”,calc_on_order_fills=false,calc_on_every_tick =false, initial_capital=20000,commission_value=.25,overlay = true,default_qty_type = strategy.cash, default_qty_value = 20000)
period=input(10, title=”Bollinger period”, minval = 5, step =5)
multipup=input(3, title=”Boll multipler up”, minval= 0.1)
multidown = input(1, title=”Boll multipler up”, minval= 0.1)
stop_loss=input(10, “Stop loss %”, minval = 1, step = 1)
bollup = sma(close,period)+stdev(close,period)multipup bolldo = sma(close, period)-stdev(close,period)multidown
//entry
entry = crossover(close,bollup)
strategy.entry(“Long”, true, when = entry)
exitup = crossunder(close,bolldo)
strategy.close(“Long”, when = exitup, comment =”cLOSE up”)
sl = -1stop_loss/100strategy.initial_capital
close_Stop = strategy.openprofit < sl
strategy.close(“Compra”, when = close_Stop, comment= “Stop loss”)
b1 = plot(bollup, title = “Boll+”)
b2= plot(bolldo, title = “Boll-“)
fill(b1, b2, color=color.purple)
Results in European market are not so good, but quite satisfactory for US. Markets