Hi all, I’ve tried with one friend to create a TS that is robust and could work on different index.
Here is a trading strategy to be run on 1 hour time-frame.
HOW IT WORKS?
Long entry if supertrend is short and the price goes over the EMA. Closing under the Bollinger bands middle.
Exit long if supertrend is long and the price goes under the EMA and the closure is under the Bollinger bands middle.
BEFORE TESTING:
Only thing to be chosen before run the backtest is the number of contracts, the starting time and end time.
The starting and end time is there to avoid to insert orders when spread during night time is too high.
SUGGESTIONS:
For DAX, EUROSTOX, CAC I suggest starting time 8 and end time 22.
For MIB I suggest starting time 8 and end time 18.
For GOLD and WTI starting time 0 and end time 24 (spread is always the same).
QUESTIONS:
Is there someone that can do a montecarlo forward test on this code?
any comments or Idea? I have also a version with money management but that would be a second step.
defparam cumulateorders = false
//PARAMETRI VARIABILI
OraInizio =8
OraFine = 22
numerocontratti = 1
//PARAMETRI FISSI
mm = 10
BB = 25
ATRvolaDown = 15
ATRvolaUp = 425
ATR = 14
x = 2.5
supertrendLow = 3
SupertrendUp = 10
EMA=exponentialaverage[mm](close)
BBmiddle= (BollingerUp[BB](close)+BollingerDown[BB](close))/2
ora=currenthour
condizioneday= ora > OraInizio and ora < OraFine
condizionevola= AverageTrueRange[ATRvolaDown](close)>AverageTrueRange[ATRvolaUp](close)
// Condizioni per entrare su posizioni long
IF NOT LongOnMarket and condizioneday and Close < Supertrend[supertrendLow,SupertrendUp] and close > ema and condizionevola THEN
BUY numerocontratti CONTRACTS AT MARKET
stopprice=AverageTrueRange[ATR](close)*x
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket AND Close > Supertrend[supertrendLow,SupertrendUp] and close < BBmiddle and close < EMA THEN
SELL AT MARKET
ENDIF
// Condizioni per entrare su posizioni short
IF NOT ShortOnMarket and condizioneday and Close > Supertrend[supertrendLow,SupertrendUp] and close < ema and condizionevola THEN
SELLSHORT numerocontratti CONTRACTS AT MARKET
stopprice=AverageTrueRange[ATR](close)*x
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket AND Close < Supertrend[supertrendLow,SupertrendUp] and close > BBmiddle and close > ema THEN
EXITSHORT AT MARKET
ENDIF
// Stop e target: Inserisci qui i tuoi stop di protezione e profit target
set stop ploss stopprice