a problem with heikin-ashi formula
Forums › ProRealTime English forum › ProScreener support › a problem with heikin-ashi formula
- This topic has 7 replies, 3 voices, and was last updated 2 years ago by gnellas77.
-
-
10/14/2022 at 12:35 PM #202560
hi gentlemen,
i have a question, i have written a simple code to detect inside bars of the same colour on heiken-ashi.
but the screener, i think, sometimes give me inconsistent results. below are the formulas that i use.
can you check it out for me where i did wrong for example? or it’s the fault of screener?
heikin ashi inside bar12345678910111213141516171819202122232425//inside candle of HA, long or shortmyhaopen = CALL "ha-open"myhaclose = CALL "ha-close"//go longc1 = myhaopen > myhaclosec2 = myhaopen[1] > myhaclose[1]c3 = myhaopen < myhaopen[1]c4 = myhaclose > myhaclose[1]//go shortc6 = (c1 and c2 and c3 and c4)c7 = myhaopen < myhaclosec8 = myhaopen[1] < myhaclose[1]c9 = myhaopen > myhaopen[1]c10 = myhaclose < myhaclose[1]c12 = (c7 and c8 and c9 and c10)screener [c6 or c12]ha-open123c1 = (open[1]+close[1])/2return (c1)ha-close123c1 = (open+close+high+low)/4return (c1)thank you.
10/14/2022 at 4:23 PM #202567This is not the correct formula for Heikin Ashi candlesticks, please use the one below:
12345678910xClose = (open+high+low+close)/4if BarIndex=0 THENxOpen = openxHigh = highxLow = lowelsexOpen = (xOpen[1] + xClose[1])/2xHigh = Max(Max(high, xOpen), xClose)xLow = Min(Min(low, xOpen), xClose)endifXopen and Xclose in your case.
1 user thanked author for this post.
10/15/2022 at 1:36 PM #202597one final question: yes now the formula works but does not include dojis. i put the equal sign but again it does not work (for the dojis).
for example on 14/10/2022 doesnot show BRENNTAG stock on dax40.
where am i wrong? thank you!
about dojis123456789101112131415161718192021222324252627//inside bar on S+R of the same color on H.A.//real formula for open+close of H.A.xClose = (open+high+low+close)/4if BarIndex=0 THENxOpen = openelsexOpen = (xOpen[1] + xClose[1])/2endif//go longc1 = xOpen >= xClosec2 = xOpen[1] > xClose[1]c3 = xOpen < xOpen[1]c4 = xClose > xClose[1]c6 = (c1 and c2 and c3 and c4)//go shortc7 = xOpen <= xClosec8 = xOPen[1] < xClose[1]c9 = xOpen > xOpen[1]c10 = xClose < xClose[1]c12 = (c7 and c8 and c9 and c10)screener [c6 or c12]10/15/2022 at 3:03 PM #202599Hi @gnellas77
Try this one…
gnellas771234567891011121314151617181920212223242526272829303132//inside bar on S+R of the same color on H.A.//real formula for open+close of H.A.xClose = (open+high+low+close)/4if BarIndex=0 THENxOpen = openelsexOpen = (xOpen[1] + xClose[1])/2endifxHigh = Max(Max(high, xOpen), xClose)xLow = Min(Min(low, xOpen), xClose)DojiSize = 0.05//go longc1 = (abs(xOpen - xClose) <= (xHigh - xLow) * DojiSize)c2 = xOpen[1] > xClose[1]c3 = xOpen < xOpen[1]c4 = xClose > xClose[1]c6 = (c1 and c2 and c3 and c4)//go shortc7 = (abs(xOpen - xClose) <= (xHigh - xLow) * DojiSize)c8 = xOPen[1] < xClose[1]c9 = xOpen > xOpen[1]c10 = xClose < xClose[1]c12 = (c7 and c8 and c9 and c10)screener [c6 or c12]1 user thanked author for this post.
10/16/2022 at 12:17 PM #202615now it catches the pure doji of BRENNTAG and the small doji of FRESENIUS but misses SYMRISE and DELIVERY HERO which have an inside bar of the same colour. That was the objective from the beginning to catch both inside bars and dojis at the same time.
i would like to have one formula for both cases. Do i have to use them seperately? by the way are the variables of xHigh and xLow necessary once i m only interested in the bodies of the candles?
thank you!!!
10/16/2022 at 8:27 PM #202634The body of the Doji is theoretically equal to zero when the Close = Open.
However, this will rarely (never?) occur and that is why you express the body of the Doji in a percentage of the range (xHigh – xLow).
For the inside bar you first have to determine whether you are looking for a “Bull Candle (xOpen < xClose)” or a “Bear Candle (xOpen > xClose)”.
So, you have to add an extra condition.
1 user thanked author for this post.
10/17/2022 at 8:36 AM #202657Examples of Doji spotted with Heikin Ashi formula, and with percentage of body compared to the range:
https://www.prorealcode.com/prorealtime-indicators/heikin-ashi-doji-candle/
https://www.prorealcode.com/prorealtime-market-screeners/heikin-ashi-doji-screener/
1 user thanked author for this post.
10/17/2022 at 9:48 PM #202745ok mr. js finally i made it. a combo was needed. my brains stuck for a while. your code i thought it was a repetition of mine to some extend.
your help was very useful. thank you very much!!!
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on