Hello everybody, this is the first time I share a strategy. I wrote this strategy, which leverages the repetitive behaviour of the volatility on EURUSD in intraday trading (30-minutes timeframe).
It basically enters a counter trend position when the volatility is over its average and the price enters the bollinger band back, and exits the position when the price goes back to a certain level of the opposite bollinger band. It accumulates the position up to three times. All values of the parameters and position size are optimized for long and short positions, in order to achieve a reasonable draw down. I’m testing this strategy in demo account since few days, what do you think?
Do you have any suggestion to improve it, especially concerning the stability and the overfitting? Do you have the chance to test it on 200k units? Thanks in advance.
// Strategia EURUSD contro trend 30 minuti Bollinger
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = true
//defparam flatbefore = 090000
//defparam flatafter = 233000
a=21
b=1.6
c=0.9
c1=1.2
d1=9
e=6
f=15
g=145
//Indicatori
BollLow = Average[a](close)-b*std[a](close) //Bollinger low entry
BollHigh = Average[a](close)+b*std[a](close) //Bollinger high entry
BollLowExitloss = Average[a](close)-c*std[a](close) //Bollinger low exit
BollHighExitloss = Average[a](close)+c*std[a](close) //Bollinger high exit
BollLowExitwin = Average[a](close)-c1*std[a](close) //Bollinger low exit
BollHighExitwin = Average[a](close)+c1*std[a](close) //Bollinger high exit
myatr = averagetruerange[d1]
MediaAtr = average[e](myatr)
myStoc=smoothedstochastic[f,3]
MyAverage=ExponentialAverage[g](close)
If MyAverage[0] > MyAverage[1] then
Fatt=1
elsif MyAverage[0]<=MyAverage[1] then
Fatt=0.5
endif
//Condizioni entrata e uscita contro trend
CondInglongCT = (close[1] crosses under BollLow) and close crosses over BollLow and (myatr>mediaatr) and mystoc<20 //and time>110000
CondIngshortCT = (close[1] crosses over BollHigh) and close crosses under BollHigh and (myatr>mediaatr) and mystoc>80 //and time>110000
g1=3 //2
h1=4 //1
i1=2 //4
l1=2 //3
g2=1 //1
h2=4 //3
i2=4 //2
l2=2 //3
//entrata long contro trend
if CondIngLongCT then
if countoflongshares = 0 then
buy g1*fatt shares at market
elsif countoflongshares = g1 then
buy h1*fatt shares at market
elsif countoflongshares = g1+h1 then
buy i1*fatt shares at market
elsif countoflongshares = g1+h1+i1 then
buy l1*fatt shares at market
endif
endif
//entrata short in trend
if CondIngShortCT then
if countofshortshares = 0 then
sellshort g2*fatt shares at market
elsif countofshortshares = g2 then
sellshort h2*fatt shares at market
elsif countofshortshares = g2+h2 then
sellshort i2*fatt shares at market
elsif countofshortshares = g2+h2+i2 then
sellshort l2*fatt shares at market
endif
endif
if longonmarket and close crosses over BollHighexitloss then
if positionperf<0 then
sell at market
else
sell at bollhighexitwin limit
endif
endif
if shortonmarket and close crosses under BollLowexitloss then
if positionperf<0 then
exitshort at market
else
exitshort at bolllowexitwin limit
endif
endif
Hi Luca, thanks for sharing your idea. I moved your post into the forum because I’m a little concerned by the overfitting of the variables. Did you conduct walk forward analysis?
Please find attached the 200k bars backtest with a 2 pips spread.
Hi Nicolas,
thank you very much for your reply, I was also concerned about overfitting, because to be honest I don’t have that much experience with interpretation of walk forward analysis output data. Do you have any link to learning documents or videos about this item?
Thanks in advance
Luca.