IchimokuDM Strategy on SAF40
Forums › ProRealTime English forum › ProOrder support › IchimokuDM Strategy on SAF40
- This topic has 8 replies, 3 voices, and was last updated 7 years ago by juanj.
-
-
06/08/2017 at 8:17 AM #37795
Okay so 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.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677//Stategy: IchimokuDM//Market: South Africa 40 Cash (ZAR2 Micro)//Timeframe: 1Hr//Spread: 15//Timezone: UTC +2Defparam Cumulateorders = FalseDefparam Flatbefore = 090000Defparam Flatafter = 170000If hour < 9 or hour > 17 then //Works in conjunction with Flat Before/After timepossize = 0If longonmarket thenSELL AT MARKETElsIf shortonmarket thenEXITSHORT AT MARKETEndIfElsepossize = 2 //Minimum position sizeEndIfP = 11 //Standard PeriodR = P*2 //Standard Period x 2I = P*3 //Standard Period x 3TS = (highest[P](high)+lowest[P](low))/2 //Tenkan-SenKS = (highest[I](high)+lowest[I](low))/2 //Kijun-SenCS = close[I] //Chikou-SpanSA = (TS+KS)/2 //Senkou-Span ASB = (highest[I](high)+lowest[I](low))/2 //Senkou-Span BDP = DIplus[R](close) //DI+DN = DIminus[R](close) //DI-AX = ADX[R] //ADXATR = AverageTrueRange[P](close)If RSI[R](close) > RSI[R](close[I]) ThenIf close < CS ThenBDIV = 1 //Buy Divergence PresentSDIV = 0EndIfEndIfIf RSI[R](close) < RSI[R](close[I]) ThenIf close > CS ThenBDIV = 0 //Sell Divergence PresentSDIV = 1EndIfEndIfIf 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] ThenBuy possize*3 contracts at close + ATR stopEndIfIf 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] ThenSellshort possize*3 contracts at close - ATR stopEndIfIf Longonmarket thenIf close < TS ThenSell possize contracts at Market //Exit third of position at close below Tenkan-Sen LineElsIf close < TS and close < KS ThenSell possize contracts at Market //Exit third of position at close below Kijun-Sen LineElsIf close < TS and close < KS and close < SA or close < SB ThenSell at market //Exit full position at close below Senkou-SpanEndIfElsIf Shortonmarket thenIf close > TS ThenExitshort possize contracts at Market //Exit third of position at close below Tenkan-Sen LineElsIf close > TS and close > KS ThenExitshort possize contracts at Market //Exit third of position at close above Kijun-Sen LineElsIf close > TS and close > KS and close > SA or close > SB ThenExitshort at market //Exit full position at close above Senkou-SpanEndIfEndIfSet Stop pLOSS ATR*4Set Target pPROFIT ATR*51 user thanked author for this post.
06/08/2017 at 8:20 AM #37798Thanks for this automatic trading strategy code. It seems to work fine on backtests, though I moved your post to the forum instead of the library, because ProOrder don’t support yet partial closure of positions and that’s what your strategy does between lines 58 to 74. I hope this will be available one day, but actually this strategy could only work in paper trading / backtest, not in real trading environment under ProOrder..Sorry for that 😐
06/08/2017 at 4:09 PM #37840Hi Nicolas
Yes it is unfortunate about ProOrder not supporting close of partial positions, however replacing lines 58 to 74 with the below code yields a very similar result to above without having to use partial position closing. So what about we modify the code and move it to the library in order for a bigger audience to benefit?
12345678910111213If Longonmarket thenIf close < TS Then //If close below Tenkan-Sen LineIf close < close[1] ThenSell at Market //Close position at next lower closeEndIfEndIfElsIf Shortonmarket thenIf close > TS Then //If close below Tenkan-Sen LineIf close > close[1] ThenExitshort at Market //Close position at next higher closeEndIfEndIfEndIf06/08/2017 at 8:41 PM #3784906/09/2017 at 8:08 AM #37864So here is the modified code with your last addition:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273//Stategy: IchimokuDM//Market: South Africa 40 Cash (ZAR2 Micro)//Timeframe: 1Hr//Spread: 15//Timezone: UTC +2Defparam Cumulateorders = FalseDefparam Flatbefore = 073000Defparam Flatafter = 163000If hour < 9 or hour > 17 then //Works in conjunction with Flat Before/After timepossize = 0If longonmarket thenSELL AT MARKETElsIf shortonmarket thenEXITSHORT AT MARKETEndIfElsepossize = 2 //Minimum position sizeEndIfP = 11 //Standard PeriodR = P*2 //Standard Period x 2I = P*3 //Standard Period x 3TS = (highest[P](high)+lowest[P](low))/2 //Tenkan-SenKS = (highest[I](high)+lowest[I](low))/2 //Kijun-SenCS = close[I] //Chikou-SpanSA = (TS+KS)/2 //Senkou-Span ASB = (highest[I](high)+lowest[I](low))/2 //Senkou-Span BDP = DIplus[R](close) //DI+DN = DIminus[R](close) //DI-AX = ADX[R] //ADXATR = AverageTrueRange[P](close)If RSI[R](close) > RSI[R](close[I]) ThenIf close < CS ThenBDIV = 1 //Buy Divergence PresentSDIV = 0EndIfEndIfIf RSI[R](close) < RSI[R](close[I]) ThenIf close > CS ThenBDIV = 0 //Sell Divergence PresentSDIV = 1EndIfEndIfIf 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] ThenBuy possize*3 contracts at close + ATR stopEndIfIf 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] ThenSellshort possize*3 contracts at close - ATR stopEndIfIf Longonmarket thenIf close < TS Then //If close below Tenkan-Sen LineIf close < close[1] ThenSell at Market //Close position at next lower closeEndIfEndIfElsIf Shortonmarket thenIf close > TS Then //If close below Tenkan-Sen LineIf close > close[1] ThenExitshort at Market //Close position at next higher closeEndIfEndIfEndIfSet Stop pLOSS ATR*4Set Target pPROFIT ATR*5I changed the time schedule between 07.30-16.30 for the intraday 8 points spread. Results attached, please confirm before I add it into the library! thanks.
1 user thanked author for this post.
06/09/2017 at 8:29 AM #37870Hi Nicholas, the results seem valid. I don’t have the amount of data points you have so mine will look slightly different. Pleased to see it still performs on par in the period outside of my optimization time frame. This actually serves as validation of the strategy.
06/09/2017 at 1:05 PM #37891The strategy is now available in our library: https://www.prorealcode.com/prorealtime-trading-strategies/ichimoku-dm-strategy-saf40-1-hour/
06/09/2017 at 4:31 PM #37907Nice idea, will take a look and post any updates.
Yea, bit of a pain with the lack of partial closures, bi-directional trading and stuff- but as quick proof of concept it’s useful.
Just for future reference guys, if you are dependent on abilities such as to execute partial closures and wish to run with such features, I could actually make that happen for you using our own tools. Wouldn’t normally disclose the screen shots attached but I think there’s some good ideas and thinking out here that is out-growing PRT. (attached is monitoring views from our system)
Best,
M
1 user thanked author for this post.
06/09/2017 at 7:10 PM #37917 -
AuthorPosts
Find exclusive trading pro-tools on