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?
//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
You must be logged in to post a comment.
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.
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
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.
Did anyone test this live?