Working on a ichimoku strategy…
Forums › ProRealTime English forum › ProOrder support › Working on a ichimoku strategy…
- This topic has 9 replies, 3 voices, and was last updated 7 years ago by pieroim.
-
-
10/04/2017 at 11:27 AM #48180
This is a very simple EA, I wrote it in the simplest way possible so that anyone can understand and work on it.
I’m not very happy with the result, the problem is that ichimoku is strongly related to the trend, and I’m thinking about how to do a prt analysis of the trend on different TSs.
Anyway, I hope you also want to work on it.Simple ichimoku strategy123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282//Stategy: Ichimoku//Author: Piero Petrosillo//version: 1//Timeframe: 15 and 30 minutes - eurusd only//Backtested from 01/11/2015 to 27/09/2017//I'm sorry for my bad english.. :-)//work in progress..Defparam CUMULATEORDERS = Falseonce segnale = 0once barcount = 0once barcountClose = 0once blocForzato = 0possize = 2//indicators---------------------------------------------------------------------------------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-SenKS = (highest[I](high)+lowest[I](low))/2 //Kijun-SenCS = close[I] //Chikou-SpanSA = (TS[I]+KS[I])/2 //Senkou-Span ASB = (highest[K](high[I])+lowest[K](low[I]))/2 //Senkou-Span BmyADX = ADX[20]//end of indicators--------------------------------------------------------------------------//Signals------------------------------------------------------------------------------------if blocForzato = 1 then //wait after the order closeif Barindex>barcountClose+2 thenblocForzato = 0endifendif//Chikou-Span position respect to the priceprezzoCSLow = low[26]prezzoCSHigh= high[26]spreadCS = pointsize*4prezzoCSLow = prezzoCSLow - spreadCSprezzoCSHigh=prezzoCSHigh + spreadCS// Tenkan-Sen/Kijun-Sen crossingnum1 = TS[0]num2 = KS[0]num1p = TS[1]num2p = KS[1]if segnale = 0 thenincrocio = 0if num1>num2 and num2p>=num1p thenincrocio = 1 //longsegnale = Barindex+2endifif num2>num1 and num1p>=num2p thenincrocio = -1//shortsegnale = Barindex+2endifendifif Barindex > segnale thensegnale = 0endif//Kumo parameterskumoUP =0kumoDOWN =0kumoUPold =0kumoDOWNold =0spesKumoMin =pointsize*1//-------------- minimum kumo size ---------------------speKum =0mode =0if SA[0]>SB[0] thenkumoUP=SA[0]kumoDOWN=SB[0]mode=3kumoUPold=SA[1]kumoDOWNold=SB[1]elsekumoUP=SB[0]kumoDOWN=SA[0]mode=4kumoUPold=SB[1]kumoDOWNold=SA[1]endifspesKumo = kumoUPold-kumoDOWNoldif spesKumo>spesKumoMin thenspeKum = 1//kumo size signalendif//mini ts trendprimo = TS[3]ultimo = TS[0]spread = pointsize*2miniTr= ultimo-primominiTr= miniTr/spread//mini price trend - not used nowprimo = typicalprice[1]ultimo = typicalprice[0]spread = pointsize*1miniTrPr= ultimo-primominiTrPr= miniTrPr/spread//ChikouSpan out of span A e B - not used now//senkChiko = 0if SA[26]>SB[26] thenif CS[26]>SB[26] and CS[26]<SA[26] then//senkChiko = 1endifelseif CS[26]>SA[26] and CS[26]<SB[26] then//senkChiko = 1endifendif//kumo sidesegnale1 =0segnale2 =0segnale3 =0segnale4 =0kumoLatLong = 0kumoLatShort = 0if mode = 3 then // A up, B downlast = SA[0]candele = SA[1]if candele > (last+spesKumoMin) then//longsegnale1 = segnale1 + 1endiflast = SB[0]candele = SB[1]if (candele+spesKumoMin) < last then//shortsegnale2 = segnale2 + 1endifendifif mode = 4 then// B up, A downlast = SB[0]candele = SB[1]if candele > (last+spesKumoMin) then//longsegnale3 = segnale3 + 1endiflast = SA[0]candele = SA[1]if (candele+spesKumoMin) < last then//shortsegnale4 = segnale4 + 1endifendifif (segnale1+segnale3) > 0 thenkumoLatLong = 1//signalendifif (segnale2+segnale4) > 0 thenkumoLatShort = 1//signalendif//end of signals------------------------------------------------------------------------------------//Orders--------------------------------------------------------------------------------------------//Chikou-Span redefinitionCS = close[0]blocco = 0//not used nowspeKum2 = 0//long position//and spesKumo>spesKumomin and senkChiko = 0 and miniTr>4 and miniTrPr>0 and incrocio = 1if myADX>15 and blocForzato=0 thenif speKum=1 then//spessore kumo buonoif countofposition = 0 and entrataAquisto = 0 and entrataVendita = 0 and incrocio=1 and TS[0]>KS[0] and CS[0]>prezzoCSHigh and miniTr>4 then//TS position compared to kumoif kumoLatLong = 0 and TS[0]>kumoUP and KS[0]>kumoUP thenspeKum2 = 1elseif kumoLatLong = 1 and TS[0]>kumoDOWNold and TS[0]<kumoUPold then //to optimize itspeKum2 = 1endifendifif blocco = 0 and speKum2 = 1 thenBuy possize contracts at marketbarcount = Barindexsegnale = 0entrataAquisto = 1EndIfendif//Short Position//and senkChiko = 0 and miniTr<-4 and miniTrPr<0 and incrocio = -1if countofposition = 0 and entrataVendita = 0 and entrataAquisto = 0 and incrocio=-1 and TS[0]<KS[0] and CS[0]<prezzoCSLow and miniTr<-4 thenif kumoLatShort = 0 and TS[0]<kumoDOWN and KS[0]<kumoDOWN thenspeKum2 = 1elseif kumoLatShort = 1 and TS[0]<kumoDOWNold and TS[0]>kumoUPold then //to optimize itspeKum2 = 1endifendifif blocco = 0 and speKum2 = 1 thenSellshort possize contracts at marketbarcount = Barindexsegnale = 0entrataVendita = 1EndIfendifelse//slim kumo -----------------------------------------//and miniTr>4 and miniTrPr>0and incrocio = 1if countofposition = 0 and entrataAquisto = 0 and entrataVendita = 0 and incrocio=1 and TS[0]>KS[0] and CS[0]>prezzoCSHigh and miniTr>4 and blocco = 0 thenBuy possize contracts at marketbarcount = Barindexsegnale = 0entrataAquisto = 1endif//and senkChiko = 0and miniTr<-4 and miniTrPr<0and incrocio = -1if countofposition = 0 and entrataVendita = 0 and entrataAquisto = 0 and incrocio=-1 and TS[0]<KS[0] and CS[0]<prezzoCSLow and miniTr<-4 and blocco = 0 thenSellshort possize contracts at marketbarcount = Barindexsegnale = 0entrataVendita = 1endifendifendif//GRAPH CS[0] coloured(0,255,0) AS "CS0"//GRAPH prezzoCSLow coloured(0,0,255) AS "prezzoCSLow"//GRAPH incrocio coloured(255,0,0) AS "incrocio"//GRAPH miniTr coloured(255,0,0) AS "miniTr"//GRAPH miniTrPr coloured(255,0,0) AS "miniTrPr"//GRAPH kumoLatShort coloured(255,0,0) AS "klat"//GRAPH TS[0] coloured(255,0,0) AS "ts0"//GRAPH FastSMA[0] coloured(255,0,0) AS "SMA"//GRAPH KS[0] coloured(255,0,0) AS "ks0"//GRAPH miniTrSma coloured(255,0,0) AS "miniTrSma"//GRAPH speKum coloured(255,0,0) AS "speKum"//End of orders-------------------------------------------------------------------------------------//Exit Conditions-----------------------------------------------------------------------------------bars = 3if entrataAquisto = 1 and TS[0]<KS[0] thenSell at marketsegnale = 0entrataAquisto = 0blocForzato=1barcountClose=Barindexendifif entrataAquisto = 1 and blocForzato = 1 thenSell at marketsegnale = 0entrataAquisto = 0blocForzato=1barcountClose=Barindexendifif entrataAquisto = 1 and Barindex>barcount+bars and close[0]<close[bars] thenSell at marketsegnale = 0entrataAquisto = 0blocForzato=1barcountClose=Barindexendifif entrataVendita = 1 and TS[0]>KS[0] thenexitshort at marketsegnale = 0entrataVendita = 0blocForzato=1barcountClose=Barindexendifif entrataVendita = 1 and blocForzato = 1 thenexitshort at marketsegnale = 0entrataVendita = 0blocForzato=1barcountClose=Barindexendifif entrataVendita = 1 and Barindex>barcount+bars and close[0]<close[bars] thenexitshort at marketsegnale = 0entrataVendita = 0blocForzato=1barcountClose=Barindexendif//Exit of exit conditions---------------------------------------------------------------------------10/05/2017 at 3:59 PM #48311How can we help you? Do you need more assistance about:
how to do a prt analysis of the trend on different TSs
❓
10/05/2017 at 4:06 PM #4831210/05/2017 at 4:30 PM #48318Not right out of the box (for now… still waiting for this crucial update 😀 ), but since Ichimoku is only built upon highest high and lowest low of different periods, we could try to get accurate values of higher timeframe, just by simulating them with periods multiplication. I think it should do the trick for Ichimoku.
1 user thanked author for this post.
10/05/2017 at 5:16 PM #48320Well done @pieroim, you are making excellent progress!
I can see that you are a seasoned coder looking at your programming style.
I will look a bit closer at your strategy and see if I can make any improvements.
I have a few tricks up my sleeve that I can try.
10/05/2017 at 5:41 PM #4832810/05/2017 at 5:58 PM #4833110/06/2017 at 7:56 AM #48362Of course, you can use contrarian pending orders to close orders at specific price. If you want to close a BUY position above its current price:
1SELL at myprice LIMITor to close the BUY position below its current price:
1SELL at myprice STOP10/10/2017 at 4:07 PM #48948Now I’m working on the code for the pseudo higher timeframe..
12345678910111213141516171819202122232425262728293031323334353637if Barindex>barcountClose+15 then //ogni 16 barrebarcountClose = Barindexhigh4h=high[0]low4h=low[0]for x = 0 to 15 doif high[x] > high1h thenhigh4h=high[x]endifif low[x] < low1h thenlow4h=low[x]endifnextpiuDM = MAX(high1h-high1h[1], 0)menoDM = MAX(low1h[1]-low1h, 0)IF piuDM > menoDM THENmenoDM = 0ENDIFIF piuDM < menoDM THENpiuDM = 0ENDIFIF piuDM = menoDM THENpiuDM = 0menoDM = 0ENDIFREM Calcolo degli indicatori direzionalipiuDI = WILDERAVERAGE[14](piuDM)menoDI = WILDERAVERAGE[14](menoDM)REM Calcolo del ADXDX = ABS(piuDI - menoDI) / (piuDI + menoDI) * 100myADX1h = WILDERAVERAGE[14](DX)endifwith the above code i would like to calculate an 4h ADX in a 15m chart .. but it does not go .. the chart values, no matter if fragmented, are far from those of a 4 hour ADX ..
10/10/2017 at 4:23 PM #48953errata/corrige..
12345678910111213141516171819202122232425262728293031323334353637if Barindex>barcountClose+15 then //ogni 16 barrebarcountClose = Barindexhigh4h=high[0]low4h=low[0]for x = 0 to 15 doif high[x] > high4h thenhigh4h=high[x]endifif low[x] < low4h thenlow4h=low[x]endifnextpiuDM = MAX(high4h-high4h[16], 0)menoDM = MAX(low4h[16]-low4h, 0)IF piuDM > menoDM THENmenoDM = 0ENDIFIF piuDM < menoDM THENpiuDM = 0ENDIFIF piuDM = menoDM THENpiuDM = 0menoDM = 0ENDIFREM Calcolo degli indicatori direzionalipiuDI = WILDERAVERAGE[223](piuDM)menoDI = WILDERAVERAGE[223](menoDM)REM Calcolo del ADXDX = ABS(piuDI - menoDI) / (piuDI + menoDI) * 100myADX4h = WILDERAVERAGE[223](DX)endifnow vorks a little better..
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on