DD – Daily Doji
Forums › ProRealTime English forum › ProBuilder support › DD – Daily Doji
- This topic has 11 replies, 2 voices, and was last updated 4 years ago by Vonasi.
Tagged: doji
-
-
04/20/2020 at 9:15 PM #127130
The idea comes from Andreas Unger on Better system trader episode 45. He talks about his trend-systems, he likes to check the previous daily candle, if its body is above or below 50% of the high-low range.
Im testing it on my trend systems and the results are very interesting. Bodyp = 0.5 (or another % if you feel like optimizing/testing it.)
1234567891011121314151617if dclose(0) > dopen(0) thena = dhigh(0) - dlow(0)b = a*bodypc = b > dclose(0) - dopen(0)elsif dclose(0) < dopen(0) thena = dhigh(0)-dlow(0)b = a*bodypc = b > dopen(0) - dclose(0)endifk = 0if c thenk = 1endifreturn kWhen i test them in my systems i use the following code:
1234timeframe(daily,updateonclose)dailydoji = CALL "Daily Doji"[0.5]C1 = (dailydoji[1] = 1)timeframe(default)Im seeing some very interesting results from using this on my 1h systems. You can optimize the % of the body and you can check for = 0 as well as = 1.
Edit: Am i doing something wrong using dopen(0) etc, then calling it with [1]? or will it work as its suppose to?
04/21/2020 at 9:26 AM #127186It’s always interesting to see how different people code the same thing! This is how I would code it:
1234567891011121314bodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifreturn resultWhen you CALL an indicator it just applies the result to each candle that it is called on so it is perfectly normal to use [1] to find out what the called result was for the previous candle.
1 user thanked author for this post.
04/21/2020 at 10:26 AM #127198I always like to try to analyse things that someone says gives an edge so here I have two indicators that will check through history on the daily chart and see what happened the next day whenever a doji type candle appeared.
The first one just records whether the next candle was a green or a red one after a low doji or a green or a red one after a high doji and the second one records whether there was a break of the doji high or a break of the doji low on the next candle for both high and low doji types.
Both indicators also calculate a datum so we can directly compare to the market norm.
So it would seem that on the EURUSD a high doji day has been followed by a green day 55% of the time rather than a red day just 44% of the time – and is 70% likely to see a break of the doji high compared to only 30% a break of the low.
A low doji day has been followed by a red candle 55% of the time and by a green 44% of the time and the doji high has been broken only 30% of the time but the low broken 70% of the time.
The norm for any candle is 50% of the time the next candle is green and 49% it is red with 1% of candles having no change in value. 47% of candles are normally followed by a break of the high and 47% a break of the low. 14% of candles neither break the high or the low.
(All %’s have been rounded in this example)
So there might be an edge to looking for dojis on the EURUSD at least.
Doji then Red or Green Tester123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263//Doji then Red or Green Tester//By Vonasi//Date: 20200421bodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifgreen = close>openred = close<opennull = close = opencount = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] = 1 thenupdojis = updojis + 1if green thengup = gup + 1endifif red thenrup = rup + 1endifendifif result[1] = -1 thendowndojis = downdojis + 1if green thengdown = gdown + 1endifif red thenrdown = rdown + 1endifendifupdojigreen = (gup/updojis)*100updojired = (rup/updojis)*100downdojigreen = (gdown/downdojis)*100downdojired = (rdown/downdojis)*100gdatum = (datumgreen/count)*100rdatum = (datumred/count)*100ndatum = (datumnull/count)*100return updojigreen as "high doji then green", updojired as "high doji then red", downdojigreen as "low doji then green", downdojired as "low doji then red", gdatum as "green datum", rdatum as "red datum", ndatum as "null datum"Doji then break of high or low tester.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263//Doji Then Break of High or Low Tester//By Vonasi//Date:20200421bodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifgreen = high > high[1]red = low < low[1]null = high < high[1] and low > low[1]count = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] = 1 thenupdojis = updojis + 1if green thengup = gup + 1endifif red thenrup = rup + 1endifendifif result[1] = -1 thendowndojis = downdojis + 1if green thengdown = gdown + 1endifif red thenrdown = rdown + 1endifendifupdojigreen = (gup/updojis)*100updojired = (rup/updojis)*100downdojigreen = (gdown/downdojis)*100downdojired = (rdown/downdojis)*100gdatum = (datumgreen/count)*100rdatum = (datumred/count)*100ndatum = (datumnull/count)*100return updojigreen as "high doji then high break", updojired as "high doji then low break", downdojigreen as "low doji then high break", downdojired as "low doji then low break", gdatum as "high break datum", rdatum as "low break datum", ndatum as "no break datum"04/21/2020 at 10:53 AM #127210Here is a third version that analyses after each doji whether the close was above the doji high or below the doji low or an inside close.
On the EURUSD it seems that the normal datum is that 50% of candles close inside and 25% close above and 25% close below the previous candle.
If we look at just high dojis then 45% close inside and 40% close above the doji high and just 15% close below the doji low the next day.
For low dojis then 43% close inside and 16% close above the doji high and 40% close below the doji low.
Doji Close Above Or Below Tester12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970//Doji Close Above Or Below Tester//By Vonasi//Date: 20200421bodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifgreen = close > high[1]red = close < low[1]null = close < high[1] and close > low[1]count = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] = 1 thenupdojis = updojis + 1if green thengup = gup + 1endifif red thenrup = rup + 1endifif null thennup = nup + 1endifendifif result[1] = -1 thendowndojis = downdojis + 1if green thengdown = gdown + 1endifif red thenrdown = rdown + 1endifif null thenndown = ndown + 1endifendifupdojigreen = (gup/updojis)*100updojired = (rup/updojis)*100downdojigreen = (gdown/downdojis)*100downdojired = (rdown/downdojis)*100gdatum = (datumgreen/count)*100rdatum = (datumred/count)*100ndatum = (datumnull/count)*100updojinull = (nup/updojis)*100downdojinull = (ndown/downdojis)*100return updojigreen as "high doji then close above high", updojired as "high doji then close below low", downdojigreen as "low doji then close above high", downdojired as "low doji then close below low", gdatum as "close above high datum", rdatum as "close below low datum", ndatum as "close inside datum", updojinull as "high doji then close inside", downdojinull as "low doji then close inside"04/21/2020 at 11:32 AM #127226@Vonasi thanks for the tools! Very interesting findings:
“So it would seem that on the EURUSD a high doji day has been followed by a green day 55% of the time rather than a red day just 44% of the time – and is 70% likely to see a break of the doji high compared to only 30% a break of the low.
A low doji day has been followed by a red candle 55% of the time and by a green 44% of the time and the doji high has been broken only 30% of the time but the low broken 70% of the time.”
Ungar uses this as a filter for his trend/swing systems, so expecting a green day that exceeds the doji-high the next day would make sense that there is actually an edge (if not he must be lying lol)
Big thanks for the good work 🙂
Edit: This is why sharing is caring on the forum, one guys reads something in a book, another guy takes the idea and runs with it 🙂
1 user thanked author for this post.
04/21/2020 at 12:59 PM #127251I ran a bit further with it.
I decided to try to rate each doji by how close the open and close were to the extreme of the candle – so for a high doji the closer both the open and close are to the candle high the higher that doji scored and the opposite for low dojis so the closer both the open and close are to the candle low the higher the score. The scores are between zero and 100.
Then thanks to v11 arrays I was able to split the results up into 80 buckets – so high dojis that were followed by a green candle and that scored 0 to 5 then >5 and <=10 then >10 and <=15 and so on – and the same for if a red candle followed and also the same for low dojis.
I then plotted the results in four charts and put the green and red datum values across them all to see if the score of a doji effects the likely hood of the next candle being a red or green one.
The numbers above the lines are the number of low dojis or high dojis with that score that were tested . The lines are scaled 0 to 100% on the y axis.
The results on the EURUSD were a little inconclusive and this is perhaps to the limited amount of data in each bucket. Perhaps in hind sight bigger buckets would have been better. However I have drawn arrows on the second image showing what looks like the general trend for each chart and it would seem that the higher a doji scores the more likely the next candle is to continue in the same direction – that is up for high dojis and down for low dojis.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122//Doji R G Scoring Tester//PRTv11//By Vonasi//Date: 20200421bodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = round((((((bodytop-midpoint)/(range/2))*100) + (((bodybottom-midpoint)/(range/2)))*100))/2)endifif bodybottom < midpoint and bodytop < midpoint thenresult = -round((((((midpoint-bodytop)/(range/2))*100) + (((midpoint-bodybottom)/(range/2)))*100))/2)endifgreen = close>openred = close<opennull = close = opencount = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] > 0 thenfor a = 1 to 20b = a*5if result[1] = b then$updojis[b] = $updojis[b] + 1if green then$gup[b] = $gup[b] + 1endifif red then$rup[b] = $rup[b] + 1endifbreakendifnextendifif result[1] < 0 thenfor a = 1 to 20b = a*5if result[1] = -b then$downdojis[b] = $downdojis[b] + 1if green then$gdown[b] = $gdown[b] + 1endifif red then$rdown[b] = $rdown[b] + 1endifbreakendifnextendifif islastbarupdate thenfor a = 1 to 20b = a*5$updojigreen[b] = ($gup[b]/$updojis[b])*100drawsegment(barindex+a,0,barindex+a,$updojigreen[b])coloured(0,128,0)text = $updojis[b]drawtext("#text#",barindex+a,$updojigreen[b]+2,sansserif,bold,10)coloured(0,128,0)$updojired[b] = ($rup[b]/$updojis[b])*100drawsegment(barindex+a+25,0,barindex+a+25,$updojired[b])coloured(128,0,0)drawtext("#text#",barindex+a+25,$updojired[b]+2,sansserif,bold,10)coloured(128,0,0)$downdojigreen[b] = ($gdown[b]/$downdojis[b])*100drawsegment(barindex+a+50,0,barindex+a+50,$downdojigreen[b])coloured(0,128,0)text = $downdojis[b]drawtext("#text#",barindex+a+50,$downdojigreen[b]+2,sansserif,bold,10)coloured(0,128,0)$downdojired[b] = ($rdown[b]/$downdojis[b])*100drawsegment(barindex+a+75,0,barindex+a+75,$downdojired[b])coloured(128,0,0)drawtext("#text#",barindex+a+75,$downdojired[b]+2,sansserif,bold,10)coloured(128,0,0)nextdrawtext("up doji then green",barindex+10,-2,sansserif,bold,10)coloured(0,128,0)drawtext("up doji then red",barindex+35,-2,sansserif,bold,10)coloured(128,0,0)drawtext("down doji then green",barindex+60,-2,sansserif,bold,10)coloured(0,128,0)drawtext("down doji then red",barindex+85,-2,sansserif,bold,10)coloured(128,0,0)gdatum = (datumgreen/count)*100drawsegment(barindex-8,0,barindex-8,gdatum)coloured(0,128,0)drawtext("#count#",barindex-7,-4,sansserif,bold,10)coloured(0,0,255)rdatum = (datumred/count)*100drawsegment(barindex-7,0,barindex-7,rdatum)coloured(128,0,0)ndatum = (datumnull/count)*100drawsegment(barindex-6,0,barindex-6,ndatum)coloured(0,0,255)drawtext("datum",barindex-7,-2,sansserif,bold,10)coloured(0,0,255)drawsegment(barindex+1,gdatum,barindex+20,gdatum)coloured(0,128,0)drawsegment(barindex+25,rdatum,barindex+45,rdatum)coloured(128,0,0)drawsegment(barindex+50,gdatum,barindex+70,gdatum)coloured(0,128,0)drawsegment(barindex+75,rdatum,barindex+95,rdatum)coloured(128,0,0)drawtext("5",barindex+1,-2,sansserif,bold,10)coloured(0,128,0)drawtext("100",barindex+20,-2,sansserif,bold,10)coloured(0,128,0)drawtext("5",barindex+25,-2,sansserif,bold,10)coloured(128,0,0)drawtext("100",barindex+45,-2,sansserif,bold,10)coloured(128,0,0)drawtext("5",barindex+50,-2,sansserif,bold,10)coloured(0,128,0)drawtext("100",barindex+70,-2,sansserif,bold,10)coloured(0,128,0)drawtext("5",barindex+75,-2,sansserif,bold,10)coloured(128,0,0)drawtext("100",barindex+95,-2,sansserif,bold,10)coloured(128,0,0)endifreturn -6 coloured(0,0,0,0),102 coloured(0,0,0,0)1 user thanked author for this post.
04/21/2020 at 1:10 PM #127254Sometimes we have to take a step back and look at the bigger picture.
The attached image is an equity curve of a strategy on the EURUSD that simple goes long on a high doji and short on a low doji and then exits the next day.
We can clearly see that up to the beginning of 1993 the strategy worked very well indeed but since then the edge disappeared. I think we can blame all those pesky computers that people started trading with again. It seems that dojis are perhaps no longer a trading edge.
04/21/2020 at 2:04 PM #12726604/21/2020 at 3:46 PM #127279It is like someone just threw a switch at the start of 1993 and the doji edge just totally disappeared!
It’s lucky I shared these codes here as my laptop just crash closed for some strange reason – perhaps because it is a rather warm day here in Greece and I haven’t got round to fitting the new cooling fan I bought for it yet! If I hadn’t shared them then they would have all been lost because I hadn’t hit CTRL+S yet today or exported them yet.
04/21/2020 at 4:26 PM #127281So I decided to run the same tests but exclude pre 1993 data. The results are very different.
The doji seems to have no effect on the colour of the following candle.
However when we compare to the high break and low break datums there is perhaps still something to see:
The datum is that 48% of all candles are followed by a break of the high and 48% a break of the low
After a high doji 70% of candles break the high and only break the low 33% of the time.
After a low doji 68% of candles break the low and only break the high 34% of the time.
When we study if the next candle closes above the doji high or below the doji low we can also see something:
The datum is that 51% of candles close inside and 24% close above and 24% close below.
After a high doji 35% close above and only 15% close below.
After a low doji 34% close below and 19% close above.
1 user thanked author for this post.
04/22/2020 at 1:16 PM #127448Here is another doji tester. This one splits the data down into high green dojis, high red dojis, low green dojis and low red dojis so we can see if the coulour of the doji has any influence on what happens next.
It would appear that on the EURUSD daily since the beginning of 1993 green dojis whether high or low dojis are ever so slightly more often followed by red candles and red dojis whether high or low dojis are ever so slightly more often followed by green candles. It might be a 1 or 2% edge!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293//Red or Green Doji then Red or Green Tester//By Vonasi//Date: 20200422//StartDate = 19930101if date >= StartDate thenbodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifgreen = close>openred = close<opennull = close = opencount = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] = 1 thenif green[1] thenupdojisgreen = updojisgreen + 1endifif red[1] thenupdojisred = updojisred + 1endifif green and green[1] thenggup = ggup + 1endifif red and red[1] thenrrup = rrup + 1endifif green and red[1] thenrgup = rgup + 1endifif red and green[1] thengrup = grup + 1endifendifif result[1] = -1 thenif green[1] thendowndojisgreen = downdojisgreen + 1endifif red[1] thendowndojisred = downdojisred + 1endifif green and green[1] thenggdown = ggdown + 1endifif red and red[1] thenrrdown = rrdown + 1endifif green and red[1] thenrgdown = rgdown + 1endifif red and green[1] thengrdown = grdown + 1endifendifupdojigreengreen = (ggup/updojisgreen)*100updojiredred = (rrup/updojisred)*100updojiredgreen = (rgup/updojisred)*100updojigreenred = (grup/updojisgreen)*100downdojigreengreen = (ggdown/downdojisgreen)*100downdojiredred = (rrdown/downdojisred)*100downdojiredgreen = (rgdown/downdojisred)*100downdojigreenred = (grdown/downdojisgreen)*100gdatum = (datumgreen/count)*100rdatum = (datumred/count)*100ndatum = (datumnull/count)*100endifreturn updojigreengreen as "high green doji then green", updojiredred as "high red doji then red", downdojigreengreen as "low green doji then green", downdojiredred as "low red doji then red", gdatum as "green datum", rdatum as "red datum", ndatum as "null datum",updojiredgreen as "high red doji then green", updojigreenred as "high green doji then red", downdojiredgreen as "low red doji then green", downdojigreenred as "low green doji then red"04/22/2020 at 6:03 PM #127509I got bored and so added even more doji analysis to the indicator. Now it analyses all types of doji, high, low, green ones and red ones and every combination of them. It also creates equity curves for if you had traded each type and then closed one candle later for both long and short directions.
You can set a start date and also subtract a spread value from each trade if you want.
I find the easiest way to view the equity curves is to make the one you want to see a thicker line in the indicator configure window so that it stands out.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146//Red or Green Doji then Red or Green Tester//By Vonasi//Date: 20200422StartDate = 19930101 //Set to zero for analysis of all data.Spread = 0if date >= StartDate thenbodytop = max(open,close)bodybottom = min(open,close)midpoint = ((range/2)+low)result = 0if bodybottom > midpoint and bodytop > midpoint thenresult = 1endifif bodybottom < midpoint and bodytop < midpoint thenresult = -1endifgreen = close>openred = close<opennull = close = opencount = count + 1if green thendatumgreen = datumgreen + 1endifif red thendatumred = datumred + 1endifif null thendatumnull = datumnull + 1endifif result[1] = 1 thenuplong = uplong + (close-open) - spreadupshort = upshort + (open-close) - spreadif green[1] thengreendoji = greendoji+1updojisgreen = updojisgreen + 1guplong = guplong + (close-open) - spreadgupshort = gupshort + (open-close) - spreadglong = glong + (close-open) - spreadgshort = gshort + (open-close) - spreadendifif red[1] thenreddoji = reddoji+1updojisred = updojisred + 1ruplong = ruplong + (close-open) - spreadrupshort = rupshort + (open-close) - spreadrlong = rlong + (close-open) - spreadrshort = rshort + (open-close) - spreadendifif green and green[1] thenggup = ggup + 1endifif red and red[1] thenrrup = rrup + 1endifif green and red[1] thenrgup = rgup + 1endifif red and green[1] thengrup = grup + 1endifupdojis = ggup+rrup+rgup+grupif green thenupg = upg + 1endifif red thenupr = upr + 1endifendifif result[1] = -1 thendownlong = downlong + (close-open) - spreaddownshort = downshort + (open-close) - spreadif green[1] thengreendoji = greendoji+1downdojisgreen = downdojisgreen + 1gdownlong = gdownlong + (close-open) - spreadgdownshort = gdownshort + (open-close) - spreadglong = glong + (close-open) - spreadgshort = gshort + (open-close) - spreadendifif red[1] thenreddoji = reddoji+1downdojisred = downdojisred + 1rdownlong = rdownlong + (close-open) - spreadrdownshort = rdownshort + (open-close) - spreadrlong = rlong + (close-open) - spreadrshort = rshort + (open-close) - spreadendifif green and green[1] thenggdown = ggdown + 1endifif red and red[1] thenrrdown = rrdown + 1endifif green and red[1] thenrgdown = rgdown + 1endifif red and green[1] thengrdown = grdown + 1endifdowndojis = ggdown+rrdown+rgdown+grdownif green thendowng = downg + 1endifif red thendownr = downr + 1endifendifrr = rrup + rrdowngg = ggup + ggdownrg = rgup + rgdowngr = grup + grdownupdojigreengreen = (ggup/updojisgreen)*100updojiredred = (rrup/updojisred)*100updojiredgreen = (rgup/updojisred)*100updojigreenred = (grup/updojisgreen)*100updojigreen = (upg/updojis)*100updojired = (upr/updojis)*100downdojigreengreen = (ggdown/downdojisgreen)*100downdojiredred = (rrdown/downdojisred)*100downdojiredgreen = (rgdown/downdojisred)*100downdojigreenred = (grdown/downdojisgreen)*100downdojigreen = (downg/downdojis)*100downdojired = (downr/downdojis)*100reddojired = (rr/reddoji)*100reddojigreen = (rg/reddoji)*100greendojired = (gr/greendoji)*100greendojigreen = (gg/greendoji)*100gdatum = (datumgreen/count)*100rdatum = (datumred/count)*100ndatum = (datumnull/count)*100endifreturn updojigreengreen as "high green doji then green%", updojiredred as "high red doji then red%", downdojigreengreen as "low green doji then green%", downdojiredred as "low red doji then red%", gdatum as "green datum%", rdatum as "red datum%", ndatum as "null datum%",updojiredgreen as "high red doji then green%", updojigreenred as "high green doji then red%", downdojiredgreen as "low red doji then green%", downdojigreenred as "low green doji then red%",updojigreen as "up doji then green%",updojired as "up doji then red%",downdojigreen as "down doji then green%",downdojired as "down doji then red%",reddojired as "red doji then red%",reddojigreen as "red doji then green%",greendojired as "green doji then red%",greendojigreen as "green doji then green%", guplong as "high green doji long", ruplong as "high red doji long", gdownlong as "low green doji long", rdownlong as "low red doji long", gupshort as "high green doji short", rupshort as "high red doji short", gdownshort as "low green doji short", rdownshort as "low red doji short",uplong as "high doji long",upshort as "high doji short",downlong as "low doji long",downshort as "low doji short",glong as "green doji long",gshort as "green doji short",rlong as "red doji long",rshort as "red doji short" -
AuthorPosts