Hi guys.
My first contribution to the strategy site. It’s based on several codes from the site, but mainly the TDI and TMS from both Nicolas and Reiner. I changed the strategy a bit so it fits the Oil- Brent Crude. It seems like that every strategy that I test need to be “adjusted” to the particular instrument. Does anyone do the same, or do you strictly keep the rule? Anyway the code has no zero bar profit nor does it have SL or TP coded, in fact it has only 15 trades over 3 month. It sure could be more “perfect” as there are some entries that could be more profitable. Unfortunately I can only backtest it 3 month. Apparently IG only hold 3 month of data for Crude Oil. It’s tested with a 3 point spread. Anyway here it is, please comment 🙂
Cheers
Kasper
//TDI OIL 2H elsborgtrading
// based on Trend Surfer DAX-Reiner/Nicolas-TMS
//http://www.prorealcode.com/prorealtime-trading-strategies/trend-surfer-dax/
//http://www.prorealcode.com/topic/trading-made-simple-tms-system/
//http://www.forexmt4.com/_MT4_Systems/Traders%20Dynamics/TDI_1.pdf
// code-Parameter
DEFPARAM CumulateOrders = true
//DEFPARAM FlatAfter = 230000
//DEFPARAM Flatbefore = 030000
//MONEY MGT//
Equity = (Strategyprofit+20000)
Risk = round(Equity/100000)
Losses = positionperf(1)<0 and positionperf(2)<0 and positionperf(3)<0
streak = positionperf(1)>0 and positionperf(2)>0 and positionperf(3)>0
if losses then
PositionSize = max(abs(round(max(3+risk-2,risk-2))),2)
elsif not losses then
PositionSize = max(abs(round(max(3+risk,risk))),2)
endif
if streak then
PositionSize = max(abs(round(max(5+risk,risk))),2)
endif
//TDI indicator
//parameters :
lengthrsi=13
lengthrsipl=2
lengthtradesl=7
//overbought and oversold values of the TDI indicator
upperzone = 68
lowerzone = 32
//heiken ashi
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
xHigh = Max(xOpen, xClose)
xLow = Min(xOpen, xClose)
endif
//indicators
r = rsi[lengthrsi](close)
mab = average[lengthrsipl](r)
mbb = average[lengthtradesl](r)
yellowMA = average[5](TypicalPrice)
yellowMAshifted = yellowMA[2]
//trade conditions
longCondition = mab crosses over mbb AND mab<50 AND xHigh>yellowMAshifted
shortCondition = mab crosses under mbb AND mab>50 AND xLow<yellowMAshifted
Longsell=mab crosses under mbb AND mab<upperzone and mab>50 AND xlow>yellowMAshifted
Shortexit= mab crosses over mbb AND mab>lowerzone and mab<50 AND xhigh>yellowMAshifted
//***************************
// open position
// long
IF Not LONGONMARKET AND longcondition THEN
BUY PositionSize CONTRACT AT MARKET
ENDIF
// short
IF Not SHORTONMARKET AND shortCondition THEN
SELLSHORT PositionSize CONTRACT AT MARKET
ENDIF
// close position
//Longsell
IF LONGONMARKET and Longsell THEN
SELL AT MARKET
ENDIF
//Shortexit
IF SHORTONMARKET and Shortexit THEN
EXITSHORT AT MARKET
ENDIF