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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
//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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Seems to work well on the DAX as well. Just change the timeframe and Stop pLOSS to ATR*3
Thanks Juanj for sharing this.
May I know what time frame you have changed for DAX?
@CKW I cannot remember but it is easy to optimize for different time-zones just comment out the Flatbefore and Flatafter times and use variables to search for the best time period. I sometimes just optimize variable x and use 8 for variable y:
If hour < x or hour > x+y
I actually completely re-wrote this strategy as I found I actually coded it VERY wrong. My new version is in my opinion probably one of the best Ichimoku strategies out there. @Nicholas are there any way I can replace this version?
Please send it to me with the contact form, thanks.
Juanj, is it possible to just paste the new code in this comment section as some people do, given that it is uncertain at the moment whether or not the code above has been updated?
Tnx, Norbert
Did you change the Kijun-Sen to the “Standard Period x 2” and corrected the Senkou-Span B so it is not the same as the Kijun-Sen calculation, but continued the use of the “Standard Period x 3” for the SPAN-B?
Hi! Thanks for sharing! Have the code been swapped to the new one? or is it the first one still in the link?
Hi there – is there maybe somewhere a new version available to look at?
*Bump*
Have the code been swapped to the new one?
No, this is still the original version. I will post the new version in the forum sometime today and share the link.
Thanks, only saw it just now.
For the latest version and discussions see the Ichimoku thread here:
https://www.prorealcode.com/topic/ichimoku-strategies-general-discussion/#post-46741
Hi Juanj. Thanks for this. I am tying it as we speak. It does not trade that often, which is fine.But I am trying to develop a short term strategy for the SA40 on the 3,5 or 10min timeframe, that trades a few time a day with small gains, that could add up to larger ones. Could you suggest some indicators to use to achieve this? I have played around with the most common ones without success. Stochastic,RSI,MADC etc.