Hi all,
It’s my first contribution.
Simple code that works with “Supertrend” and “Commodity Channel Index” Indicators.
Run on: standard Crude Oil contract (Oil US Crude)
Timeframe: 30 Min
Period from 21-Dic-2015 to 22-Oct-2016: best result with this parameters
Spread: 3
I didn’t try with real money but considering that it works with only 2 indicators, I think it should be no problem.
Never close deal on zero bar.
For verify and testing it, you can activate Supertrend on the price chart.
Try to activate Reinvest Capital with RISK Param=44 on the same period.
Adjust parameters for different Timeframe or others products.
Some suggestions for improving the code?
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 50 51 52 53 54 55 56 57 58 59 |
//Supertrend and "Commodity Channel Index" Strategy //Oil US - Crude //Timeframe: 30 Min //Test from 21-Dic-2015 17:30 to 21-Oct-2016 22:30 DEFPARAM CumulateOrders = False // Cumulating positions deactivated //defparam flatafter = 210000 //defparam flatbefore = 010000 ca1=low <= Supertrend[3,10] ca2=close > Supertrend[3,10] IccI=CCI[20](typicalPrice) ONCE Comprato=0 ONCE Venduto=0 sl=42 //Stop Loss tp=1760 //Take Profit in Currency TagliaPosizione = 1 // ------------------------------------------- START - Reinvest Capital //RISK=90 //(Risk 10 High to 90 Low) - 44 Best Result //CapitaleIniziale=10000 //STRPR=Strategyprofit-((StrategyProfit*26)/100) //StrategyProfit - Italy TAX //TagliaPosizione=round(((STRPR+CapitaleIniziale)*0.02)/RISK) If TagliaPosizione >= 1000 then TagliaPosizione = 1000 endif // ------------------------------------------- END - Reinvest Capital // Condizioni per entrare su posizioni long IF NOT LongOnMarket AND (ca2 AND IccI > -100) THEN If Comprato=0 then //Only one buy position everytime "supertrend" change BUY TagliaPosizione CONTRACTS AT MARKET Comprato=1 Venduto=0 endif ENDIF // Condizioni per uscire da posizioni long If LongOnMarket AND ca1 THEN SELL AT MARKET ENDIF // Condizioni per entrare su posizioni short IF NOT ShortOnMarket AND (ca1 AND IccI < 100) THEN If Venduto=0 then //Only one sell position everytime "supertrend" change SELLSHORT TagliaPosizione CONTRACTS AT MARKET Venduto=1 Comprato=0 endif ENDIF // Condizioni per uscire da posizioni short IF ShortOnMarket AND ca2 THEN EXITSHORT AT MARKET ENDIF SET STOP PLOSS sl SET TARGET $PROFIT tp * TagliaPosizione |
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
Thank you Dany to contribute to our prorealtime code library 🙂
Even since 200k bars testing were not so great than the last year result, strategy isn’t so bad at all. An intraday strategy is hard to achieved on commodities and you have made it with current indicators with their default parameters. Well done. I’m looking forward for your next contribution.
Thanks, have downloaded and will check it tomorrow
Supertrend looks really cool! I will post something once it’s worth consideration. Thanks Dany 🙂
Hi, a couple of suggestions:
use CROSS OVER and CROSS UNDER with CCI, this way you catch the beginning of the move and can open up to the possibility of cumulate orders
once surfing the super trend, find new entry points like when the CCI makes V shape, again with cumulation.
cheers
Thanks for your suggestions Philippo. Sounds good…. I’ll try as soon as possibile.
Have a nice day.
Did anyone test this live?
I did it on demo account; it’s too dangerous for mea and I can not resist psychologically …., but it’s perfectly aligned to backtest, so you can try it in order to verify the performance in the last 40 days … 🙂 About 5.000 euros
Have a nice gain !
How can a demo account be dangerous?
Did you have it run live (on a demo account for example) for let’s say, a month or so?
Yes, I mean that I tried on a demo account for 2 months and it had work fine, like the BackTesting, but there are a lot of consecutive losses.If you start in a wrong way and you take immediately all the consecutive losses, it’s hard to recover them. So, I suggest you to consider this thing and to test well before take a decision to use it.
It does work very well with an high volatility.
Ciao.