ProRealCode - Trading & Coding with ProRealTime™
@volpiemanuele as requested, here the Ichimoku discussion thread. You are welcome to share your ideas related to Ichimoky trading and strategies here.
This is my latest Ichimoku strategy, it was optimized for the South African 40 Cash Market and the 1 Hour Timeframe:
//Stategy: Ichimoku
//Author: Juan Jacobs (Jd3gjacobs@gmail.com)
//Market: South Africa 40 Cash (ZAR2 Micro)
//Timezone: UTC +2
//Timeframe: 1Hr
//Spread: 20
Defparam Cumulateorders = False
//MH = (hour >= 9 or (hour = 9 and minute > x)) and (hour <= 16 or (hour = 16 and minute < 55))
possize = 2
//Standard Ichimoku Variables (Do not optimize)
T = 9 //Tenkan-Sen Period (9)
I = 26 //Chikou-Span Period (26)
K = 52 //Kijun-Sen Period (52)
TS = (highest[T](high)+lowest[T](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[K](high)+lowest[K](low))/2 //Senkou-Span B
//Additional Criteria Variables (Can be optimized)
DP = DIplus[I](close) > 20//Check strenght of Positive Directional Movement
DN = DIminus[I](close) > 20 //Check strenght of Negative Directional Movement
AX = ADX[20] > 10 //Check strenght of volitility
RS = RSI[2](close) //RSI Period to determine momentum
Period = 6
Deviations = 1.6
PRICE = LOG(customclose)
alpha = 2/(PERIOD+1)
if barindex < PERIOD then
EWMA = AVERAGE[3](PRICE)
else
EWMA = alpha * PRICE + (1-alpha)*EWMA
endif
error = PRICE - EWMA
dev = SQUARE(error)
if barindex < PERIOD+1 then
var = dev
else
var = alpha * dev + (1-alpha) * var
endif
ESD = SQRT(var)
Ua = EXP(EWMA + (DEVIATIONS*ESD))
La = EXP(EWMA - (DEVIATIONS*ESD))
Ub = Average[25,1](close)+2.5*std[25](close)
Lb = Average[25,1](close)-2.5*std[25](close)
BollU = (Ua + Ub)/2
BollL = (La + Lb)/2
BollM = EXP(EWMA)
SlowEMA = Average[20,2](close)
FastEMA = Average[5,2](close)
MinMA = Average[2,1](close)
ATR = AverageTrueRange[2](close) //Average TRue Range calculated over the last x periods
If close[1] > open[1] Then
HighestCO = close[1]
ElsIf close[1] < open[1] Then
HighestCO = open[1]
EndIf
If close[1] < open[1] Then
LowestCO = close[1]
ElsIf close[1] > open[1] Then
LowestCO = open[1]
EndIf
MaxRng = abs(open[1]-close[1])
For s = 2 to 27
If close[s] > open[s] Then
If close[s] > HighestCO Then
HighestCO = close[s]
EndIf
ElsIf close[s] < open[s] Then
If open[s] > HighestCO Then
HighestCO = open[s]
EndIf
EndIf
If close[s] < open[s] Then
If close[s] < LowestCO Then
LowestCO = close[s]
EndIf
ElsIf close[s] > open[s] Then
If open[s] < LowestCO Then
LowestCO = open[s]
EndIf
EndIf
If abs(open[s]-close[s]) > MaxRng Then
MaxRng = abs(open[s]-close[s])
EndIF
Next
If RSI[20](close) > RSI[20](close[I]) Then
If close < CS Then
BDIV = 1 //Buy Divergence Present
SDIV = 0
EndIf
EndIf
If RSI[20](close) < RSI[20](close[I]) Then
If close > CS Then
BDIV = 0 //Sell Divergence Present
SDIV = 1
EndIf
EndIf
//Check for sufficient thickness of the varios Ichimoku cloud components
KTRNG = ABS(KS - TS) > ATR*0.08
ABRNG = ABS(SA - SB) > ATR*0.2
ABIRNG = ABS(SA[I] - SB[I]) > ATR*0.2
ABKRNG = ABS(SA[K] - SB[K]) > ATR*0.08
//Check that price is not too far away from mean
MDC = (ABS(KS-close) < ATR*7)
//Criteria to Enter Long Position
If countofposition = 0 and SDIV = 0 and RS > 50 and AX and DP > DN and TS > KS and SlowEMA > SlowEMA[10] and FastEMA > FastEMA[20] and MDC and KTRNG and ABKRNG and ABIRNG and ABRNG and close > SA[I] and close > SB[I] + ATR and close > CS + ATR Then
Buy possize contracts at market
optimize = optimize + 1
LE = 0
EndIf
//Criteria to Enter Short Position
If countofposition = 0 and BDIV = 0 and RS < 50 and AX and DP < DN and TS < KS and SlowEMA < SlowEMA[10] and FastEMA < FastEMA[20] and MDC and KTRNG and ABKRNG and ABIRNG and ABRNG and close < SA[I] and close < SB[I]- ATR and close < CS - ATR Then
Sellshort possize contracts at close - ATR stop
optimize = optimize + 1
SE = 0
EndIf
//Exit Conditions
If Longonmarket and ((close[2] > BollU and close[1] > BollU and close < BollU) or (high[1] > BollU and high < BollU) or (close[2] > BollM and close[1] < BollM and close < BollM)) Then
LE = 1
ElsIf Shortonmarket and ((close[2] < BollL and close[1] < BollL and close > BollL) or (low[1] < BollL and Low > BollL) or (close[2] < BollM and close[1] > BollM and close > BollM)) Then
SE = 1
EndIf
If Longonmarket and close[1] < KS and close[1] < FastEMA and close < KS and RS < 50 and (MinMA < MinMA[16] or FastEMA < FastEMA[22] or SlowEMA < SlowEMA[35]) or (open > BollU and close < BollU) or (close[2] > open[2] and close[2] > BollU and close[1] > open[1] and close[1] > BollU and close < open and close < BollU) or (close[1] > BollU and close < open and close < close[1]) or (high[2] > BollU and high[1] > BollU and high[1] > high[2] and high[2] > high and close[2] > open[2] and close < open) or (close[1] < open[1] and close < open and high[1] > BollU and high > BollU) or (close < LowestCO and abs(open-close) > MaxRng) Then
LE = 2
ElsIf Shortonmarket and close[1] > KS and close[1] > FastEMA and close > KS and RS > 50 and (MinMA > MinMA[16] or FastEMA > FastEMA[22] or SlowEMA > SlowEMA[35]) or (open < BollL and close > BollL) or (close[2] < open[2] and close[2] < BollL and close[1] < open[1] and close[1] < BollL and close > open and close > BollL) or (close[1] < BollL and close > open and close and close > close[1]) or (low[2] < BollL and low[1] < BollL and low[1] < low[2] and low[2] > low and close[2] < open[2] and close > open) or (close[1] > open[1] and close > open and low[1] < BollL and low < BollL) or (close > HighestCO and abs(open-close) > MaxRng) Then
SE = 2
EndIf
If longonmarket and ((LE = 1 and RS >= 95) or LE = 2) Then
Sell at market
ElsIf shortonmarket and ((SE = 1 and RS <= 5) or SE = 2) Then
Exitshort at market
EndIf
Does anyone have a ichimoku indicator for price chart they could share? 🙂
Just try the search box of the website and you’ll find many Ichimoku codes! So easy …
@juanj I always learn a lot from your codes so thanks for sharing! However, I have one question; don’t you find the amount of entry criteria used in the code to be a bit excessive? If you would like to explain your thoughts with regards to this I’m eager to hear 🙂
@victormork short answer to your question yes, I do find it excessive and therefore I do not personally trade this type of strategy live via ProOrder. All the strategies I trade live nowadays via ProOrder are very simplistic and market neutral.
However, the above strategy was designed to mimic the way I trade Ichimoku manually, other versions of the code were even more ‘excessive’ and even included Fibonacci and Pivot Levels as part of the exit criteria. When I trade Ichimoku manually I consider a lot of criteria as I usually aim to only catch the big trends and ignore the minor ones. The above was thus an attempt to automate my decision-making process when it comes to Ichimoku. Although it doesn’t even include Ichimoku Time or Wave theory as I simply do not know how to code such elements into an automated strategy.
Because of all the moving parts of this Ichimoku strategy, it obviously needs to be customized for a specific market. The above example is optimized for my local index and performs respectively.
I was able to trim down and simplify your code significantly. It still does the same but gets rid of about 1 1/2 page of code. You had there this FOR-loop and nested in it several IF-loops. I could trim this down to just 3 lines.
Then I did a little bit tidying up just to make it easier to read for me. Maybe somebody else likes it.
Just to make this sure. I did not change anything. I just sorted a little bit and introduced the loopback variable so you can run WFA on it – doesn’t look that bad.
I also tried to exchange all your exit conditions for a trailing SL + dynamic TP but the result was worse than with your advanced exit conditions, so I left them.
I used Ichimoku for many years for analysing charts and identifying entry/exit points. But I never had to modify any parameters depending on the market. The only thing I found out, was, that not every timezone is giving reliable signals. So what is the reason for this South African optimization.
Thanks for sharing your insights.
Hi Masala
All the standard components, parameters, and triggers of my Ichimoku strategy remains ‘unoptimized’.
However, as you would well know because Ichimoku is a trend trading strategy it can trigger many false signals when the market is simply ranging.
Therefore I have added additional parameter to weed out false signals. For example ADX strength and Divergence checks, these, however, are very dependent on the type of market and hence different parameters are required for these. As a human, you can much more easily identify trending markets and hence do not require these signal filters.
@juanj I’ve been trying to keep all my strategies for proorder far more simple as you said yourself, but I found your concept interesting and will study it a bit more for myself. Also I just want to thank you for adapting it on the South African index, a market that I’m normally not paying any attention to 🙂
Hi, I was looking over the code and divided every entry criteria on a separate line to see which of them had the largest impact on the result. I found out that a few of them didn’t really contribute so I took them out. I have not gone over the exit in detail but I’m pasting the code here if anyone else what to have a go. Btw when I tested the code I found that the short entry was too close to the market so I added a little correction for this.
//Stategy: Ichimoku
//Author: Juan Jacobs (Jd3gjacobs@gmail.com)
//Market: South Africa 40 Cash (ZAR2 Micro)
//Timezone: UTC +2
//Timeframe: 1Hr
//Spread: 20
Defparam Cumulateorders = False
//MH = (hour >= 9 or (hour = 9 and minute > x)) and (hour <= 16 or (hour = 16 and minute < 55))
possize = 2
//tradingtime = currenttime > 080000 and currenttime < 240000 // 10 och 16, 24
//Standard Ichimoku Variables (Do not optimize)
T = 9 //Tenkan-Sen Period (9)
I = 26 //Chikou-Span Period (26)
K = 52 //Kijun-Sen Period (52)
TS = (highest[T](high)+lowest[T](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[K](high)+lowest[K](low))/2 //Senkou-Span B
//Additional Criteria Variables (Can be optimized)
DP = DIplus[I](close) > 20//Check strenght of Positive Directional Movement
DN = DIminus[I](close) > 20 //Check strenght of Negative Directional Movement
AX = ADX[20] > 10 //Check strenght of volitility
RS = RSI[2](close) //RSI Period to determine momentum
Period = 6
Deviations = 1.6
PRICE = LOG(customclose)
alpha = 2/(PERIOD+1)
if barindex < PERIOD then
EWMA = AVERAGE[3](PRICE)
else
EWMA = alpha * PRICE + (1-alpha)*EWMA
endif
error = PRICE - EWMA
dev = SQUARE(error)
if barindex < PERIOD+1 then
var = dev
else
var = alpha * dev + (1-alpha) * var
endif
ESD = SQRT(var)
Ua = EXP(EWMA + (DEVIATIONS*ESD))
La = EXP(EWMA - (DEVIATIONS*ESD))
Ub = Average[25,1](close)+2.5*std[25](close)
Lb = Average[25,1](close)-2.5*std[25](close)
BollU = (Ua + Ub)/2
BollL = (La + Lb)/2
BollM = EXP(EWMA)
SlowEMA = Average[20,2](close)
FastEMA = Average[5,2](close)
MinMA = Average[2,1](close)
ATR = AverageTrueRange[2](close) //Average TRue Range calculated over the last x periods
If close[1] > open[1] Then
HighestCO = close[1]
ElsIf close[1] < open[1] Then
HighestCO = open[1]
EndIf
If close[1] < open[1] Then
LowestCO = close[1]
ElsIf close[1] > open[1] Then
LowestCO = open[1]
EndIf
MaxRng = abs(open[1]-close[1])
For s = 2 to 27
If close[s] > open[s] Then
If close[s] > HighestCO Then
HighestCO = close[s]
EndIf
ElsIf close[s] < open[s] Then
If open[s] > HighestCO Then
HighestCO = open[s]
EndIf
EndIf
If close[s] < open[s] Then
If close[s] < LowestCO Then
LowestCO = close[s]
EndIf
ElsIf close[s] > open[s] Then
If open[s] < LowestCO Then
LowestCO = open[s]
EndIf
EndIf
If abs(open[s]-close[s]) > MaxRng Then
MaxRng = abs(open[s]-close[s])
EndIF
Next
If RSI[20](close) > RSI[20](close[I]) Then
If close < CS Then
BDIV = 1 //Buy Divergence Present
SDIV = 0
EndIf
EndIf
If RSI[20](close) < RSI[20](close[I]) Then
If close > CS Then
BDIV = 0 //Sell Divergence Present
SDIV = 1
EndIf
EndIf
//Check for sufficient thickness of the varios Ichimoku cloud components
KTRNG = ABS(KS - TS) > ATR* 0.04 //0.08
ABRNG = ABS(SA - SB) > ATR*0.2
ABIRNG = ABS(SA[I] - SB[I]) > ATR*0.2
ABKRNG = ABS(SA[K] - SB[K]) > ATR*0.01 //0.08
//Check that price is not too far away from mean
MDC = (ABS(KS-close) < ATR*7)
//Criteria to Enter Long Position
B1 = countofposition = 0
B1 = B1 and SDIV = 0
B1 = B1 and close > SA[I] and close > SB[I] + ATR
B1 = B1 and RS > 50
B1 = B1 and AX
B1 = B1 and DP > DN
B1 = B1 and TS > KS
B1 = B1 and MDC
B1 = B1 and KTRNG
B1 = B1 and ABKRNG
B1 = B1 and ABIRNG
B1 = B1 and ABRNG
//No diffrence
//B1 = B1 and close > CS + ATR
//B1 = B1 and SlowEMA > SlowEMA[10]
//B1 = B1 and FastEMA > FastEMA[20]
If B1 Then
Buy possize contracts at market
LE = 0
EndIf
//Criteria to Enter Short Position
sentry = close - ATR //make sure that stop entry is not to close to the market
If sentry < 100 then
sentry = 101
endif
S1 = countofposition = 0
S1 = S1 and BDIV = 0
S1 = S1 and close < SA[I]+ATR
S1 = S1 and RS < 50
S1 = S1 and AX
S1 = S1 and DP < DN
S1 = S1 and TS < KS
S1 = S1 and MDC
S1 = S1 and KTRNG
S1 = S1 and ABKRNG
S1 = S1 and ABIRNG
S1 = S1 and ABRNG
S1 = S1 and close < SB[I]- ATR
// No difference
//S1 = S1 and close < CS - ATR
//S1 = S1 and SlowEMA < SlowEMA[10]
//S1 = S1 and FastEMA < FastEMA[20]
If S1 Then
Sellshort possize contracts at sentry stop
SE = 0
EndIf
//Exit Conditions
If Longonmarket and ((close[2] > BollU and close[1] > BollU and close < BollU) or (high[1] > BollU and high < BollU) or (close[2] > BollM and close[1] < BollM and close < BollM)) Then
LE = 1
ElsIf Shortonmarket and ((close[2] < BollL and close[1] < BollL and close > BollL) or (low[1] < BollL and Low > BollL) or (close[2] < BollM and close[1] > BollM and close > BollM)) Then
SE = 1
EndIf
If Longonmarket and close[1] < KS and close[1] < FastEMA and close < KS and RS < 50 and (MinMA < MinMA[16] or FastEMA < FastEMA[22] or SlowEMA < SlowEMA[35]) or (open > BollU and close < BollU) or (close[2] > open[2] and close[2] > BollU and close[1] > open[1] and close[1] > BollU and close < open and close < BollU) or (close[1] > BollU and close < open and close < close[1]) or (high[2] > BollU and high[1] > BollU and high[1] > high[2] and high[2] > high and close[2] > open[2] and close < open) or (close[1] < open[1] and close < open and high[1] > BollU and high > BollU) or (close < LowestCO and abs(open-close) > MaxRng) Then
LE = 2
ElsIf Shortonmarket and close[1] > KS and close[1] > FastEMA and close > KS and RS > 50 and (MinMA > MinMA[16] or FastEMA > FastEMA[22] or SlowEMA > SlowEMA[35]) or (open < BollL and close > BollL) or (close[2] < open[2] and close[2] < BollL and close[1] < open[1] and close[1] < BollL and close > open and close > BollL) or (close[1] < BollL and close > open and close and close > close[1]) or (low[2] < BollL and low[1] < BollL and low[1] < low[2] and low[2] > low and close[2] < open[2] and close > open) or (close[1] > open[1] and close > open and low[1] < BollL and low < BollL) or (close > HighestCO and abs(open-close) > MaxRng) Then
SE = 2
EndIf
If longonmarket and ((LE = 1 and RS >= 95) or LE = 2 ) Then
Sell at market
ElsIf shortonmarket and ((SE = 1 and RS <= 5) or SE = 2 ) Then
Exitshort at market
EndIf
Set stop ploss 700 // (ATR * 30)*pointsize
Ichimoku Strategies (General Discussion)
This topic contains 10 replies,
has 6 voices, and was last updated by victormork
8 years, 3 months ago.
| Forum: | General Trading: Market Analysis & Manual Trading |
| Language: | English |
| Started: | 08/10/2017 |
| Status: | Active |
| Attachments: | 1 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.