DANY

SuperTrend and Commodity Channel Index Strategy

Category: Strategies By: DANY Created: October 23, 2016, 3:00 PM
October 23, 2016, 3:00 PM
Strategies
9 Comments
SuperTrend and Commodity Channel Index Strategy

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

 

Download
Filename: USoil-SuperTrend-CCI-TS.itf
Downloads: 518
DANY
DANY Senior
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

demoz
10 years ago
#

Did anyone test this live?

demoz
10 years ago
#

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?

DANY
10 years ago
#

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.

DANY
10 years ago
#

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 !

Philippo
10 years ago
#

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

DANY
10 years ago
#

Thanks for your suggestions Philippo. Sounds good.... I'll try as soon as possibile.

Have a nice day.

Philippo
10 years ago
#

Supertrend looks really cool! I will post something once it's worth consideration. Thanks Dany :)

Philippo
10 years ago
#

Thanks, have downloaded and will check it tomorrow

Nicolas
10 years ago
#

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.  

ProRealCode ProRealCode
Loading...