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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi David, thanks for sharing your strategy. Your contribution is much appreciated. Hope you’ll get what you are looking for into automated trading 🙂
Probably a lot of people will see the trend line and think that it is not soo good compered with other trend line in this forum but please try to run it on other index also. It is there that you have good performance!
Straight equity curve line is a trap, as we already discussed david. I’ll have a look on this code with my MonteCarlo matrix.
On prorealtime CFD, you can test the strategy since May 2006.The results are interesting.
It’s winning since 2009, with a drawdown from August 2013 to December 2014.
Thanks for sharing.Regards,
Hi Nicolas! thanks for testing with montecarlo!! I think that best index to use are CAC WTI MIB and DAX. I am running it on test IG to see if real orders are like the backtested and for the moment it seems like this. If you will think that the system could be good I will share another code to avoid exit during the night for those index with increasing of the spread. Let me know if you want me to change the code in english… I saw only now that it is in italian. Sorry.
Hi have another setup for this that was the original one:
//FIXED PARAMETERS
mm = 10
BB = 20
ATRvolaDown = 10
ATRvolaUp = 40
ATR = 14
x = 2
supertrendLow = 3
SupertrendUp = 10
These parameters should not have any curve fitted problems…
@doctortrading… any suggestions to improve it?
David
Default indicators periods tend to be less curve-fitted you’re right, since these are the most used ones in the past and surely be in the future by the masses.
Hi David!This looks really interesting. I’m a beginner, and unforunately I don’t understand italian.I Would greatly appreciate if you could translate the comments into english, as it would help me to get new ideas on how to create systems of my own.Keep it up!
You are right Nicholas… this is why I have not choosen yet which of these 2 sets of paramenter should be used. We have to remember that the curve fitted could it be done also on multiple indexes and not only one.
The forward test could give us some better idea.
As said at the beginning this TS should not be run in only one Index. In the image in the link you can find the profit line of MIB,CAC, GOLD, DAX, EUROSTOCK all togheter. These lines consider the spread already!
https://www.dropbox.com/s/5yvmsfncypuahpn/Supetrend.png?dl=0
For everyone information this strategy is also discussed in the forums on this thread: http://www.prorealcode.com/topic/robustness-in-automated-algorithmic-trading-systems/
Hi David. First question is why do you enter LONG if price is below the SuperTrend? And comment is have you tried ADX as an entry filter?
We try to enter before that the market actually turn. We try to anticipate it. In which way would you use ADX?
David-1984 are you saying that you’ve already factored in the spread within the code?
If yes, where have you done that?
no, not in teh code… only in the backtest. The entry is only between 8/22 so the spread for dax is 1 for most of the trades and 2 for the ones after 18.00 and before 22.00