I wrote this strategy today after studying some Ichimoku Trading Stategies.
It is mainly based around Ichimoku breakout strategy but also includes checks for Directional Movement and Divergence.
I wrote it for my local market (South Africa 40 Cash) on the 1Hr Timeframe on which it performs okay, which is no mean feat.
But to be completely honest i am disappointed with Ichimoku as an automated strategy in general.
But enough mumbling. Here is the code, maybe someone will find it useful.
Time schedule are adapted to intraday spread (8 points).
//Stategy: IchimokuDM
//Market: South Africa 40 Cash (ZAR2 Micro)
//Timeframe: 1Hr
//Spread: 15
//Timezone: UTC +2
Defparam Cumulateorders = False
Defparam Flatbefore = 073000
Defparam Flatafter = 163000
If hour < 9 or hour > 17 then //Works in conjunction with Flat Before/After time
possize = 0
If longonmarket then
SELL AT MARKET
ElsIf shortonmarket then
EXITSHORT AT MARKET
EndIf
Else
possize = 2 //Minimum position size
EndIf
P = 11 //Standard Period
R = P*2 //Standard Period x 2
I = P*3 //Standard Period x 3
TS = (highest[P](high)+lowest[P](low))/2 //Tenkan-Sen
KS = (highest[I](high)+lowest[I](low))/2 //Kijun-Sen
CS = close[I] //Chikou-Span
SA = (TS+KS)/2 //Senkou-Span A
SB = (highest[I](high)+lowest[I](low))/2 //Senkou-Span B
DP = DIplus[R](close) //DI+
DN = DIminus[R](close) //DI-
AX = ADX[R] //ADX
ATR = AverageTrueRange[P](close)
If RSI[R](close) > RSI[R](close[I]) Then
If close < CS Then
BDIV = 1 //Buy Divergence Present
SDIV = 0
EndIf
EndIf
If RSI[R](close) < RSI[R](close[I]) Then
If close > CS Then
BDIV = 0 //Sell Divergence Present
SDIV = 1
EndIf
EndIf
If countofposition = 0 and BDIV = 1 and AX > 17 and DP > 20 and DP > DN and close > SA and close > SB and TS > KS and close > CS and Close > SA[I] and Close > SB[I] Then
Buy possize*3 contracts at close + ATR stop
EndIf
If countofposition = 0 and SDIV = 1 and AX > 17 and DN > 20 and DP < DN and close < SA and close < SB and TS < KS and close < CS and Close < SA[I] and Close < SB[I] Then
Sellshort possize*3 contracts at close - ATR stop
EndIf
If Longonmarket then
If close < TS Then //If close below Tenkan-Sen Line
If close < close[1] Then
Sell at Market //Close position at next lower close
EndIf
EndIf
ElsIf Shortonmarket then
If close > TS Then //If close below Tenkan-Sen Line
If close > close[1] Then
Exitshort at Market //Close position at next higher close
EndIf
EndIf
EndIf
Set Stop pLOSS ATR*4
Set Target pPROFIT ATR*5