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

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 Senior
This author is like an anonymous function, present but not directly identifiable. More details on this code architect as soon as they exit 'incognito' mode.
Author’s Profile

Comments

Logo Logo
Loading...