ABCD pattern using arrays – help needed please
Forums › ProRealTime English forum › ProBuilder support › ABCD pattern using arrays – help needed please
- This topic has 3 replies, 2 voices, and was last updated 2 years ago by robertogozzi.
-
-
04/05/2022 at 1:04 PM #191229
Hi there,
I’ve been trying to find an open source ABCD pattern indicator on here for some time. I know Roberto has done an excellent job with the following indicator:
https://www.prorealcode.com/prorealtime-indicators/abcd-pattern-indicator
but I thought there must be a neater way of doing it utilising the new array functionality. Plus if you look at the first 35 mins price action today on the DAX after the market open at 8.00am (BST), whatever you set the parameter LMinBars to, it doesn’t seem to capture the ‘major’ 100% ABCD between 0812 and 0828 (in blue). It is valid as the retracement is just over 38.2% as per the text on the chart. I know Roberto’s indicator isn’t designed to capture ABCD extensions, but it would be great if an ABCD indicator could also capture the 127.2% extension in red. The attached picture shows those ABCDs marked on the chart plus Roberto’s outstanding indicator with LMinBars set to 2. I have coloured it orange to make it more visible.
So I had a go myself, using Nicolas’s array-based double top/bottom code as a template (https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/page/2/#post-120721), but struggled – kept getting infinite loop errors.
This is my attempt for what it’s worth:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768// https://www.prorealcode.com/TOPic/array-variables-availability-in-prorealtime/// (please do not remove the link above for future reference)// Example #6: flat base triangle or double TOP/bottomdefparam drawonlastbaronly=true// --- settingsfractalP = 10 // fractal periodbarlimit = 100 // maximum no. of bars between points B and D of ABCD pattern// --- end of settings//fractalscp = fractalPif high[cp] >= highest[(cp)*2+1](high) then //new fractal high found$TOPy[lastset($TOPy)+1] = high[cp] //store fractal value$TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindexendif// if low[cp] <= lowest[(cp)*2+1](low) then //new fractal low found// $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value// $BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindex// endifif(islastbarupdate and isset($TOPy[0])) then // and isset($boty[0])//check points in a range of X percentfor i = 0 to lastset($TOPy) do //loop through the topsfor y = 0 to lastset($TOPy) do //check first top with other topschange = abs(($TOPy[y]-$TOPy[i])/$TOPy[i]) //percent delta between the 2 topsbardiff = abs($TOPx[i]-$TOPx[y]) //how many bars between the 2 points?if change >= percent/100 and bardiff >= fractalP and bardiff < barlimit and $TOPx[i] <> $TOPx[y] thenPointDLevel = max($TOPy[i],$TOPy[y])PointDIndex = max($TOPx[i],$TOPx[y])PointBLevel = min($TOPy[i],$TOPy[y])PointBIndex = min($TOPx[i],$TOPx[y])PointCLevel = lowest[bardiff](low)[barindex-PointDIndex]PointCIndex = 0for a = 0 to bardiff doif low[a+(barindex-PointDIndex)] = PointCLevel thenPointCIndex = PointDIndex-abreakendifnextbardiffPointCtoD = PointDIndex-PointCIndexPointALevel = 0PointAIndex = 0for b = -barsmarginerror to barsmarginerror doif low[(barindex-PointBIndex)+bardiffPointCtoD+b] = lowest[bardiffPointCtoD+b+cp](low)[barindex-PointBIndex] thenPointALevel = low[(barindex-PointBIndex)+bardiffPointCtoD+b]PointAIndex = PointBIndex-bardiffPointCtoD-bbreakendifnextif (PointBLevel-PointCLevel) >= (Fibthreshold1*(PointBLevel-PointALevel)) and (PointBLevel-PointCLevel) >= (Fibthreshold2*(PointBLevel-PointALevel)) thenABCD = 1DRAWSEGMENT(PointCIndex,PointCLevel,PointDIndex,PointDLevel)coloured(255,10,10) style(line)DRAWSEGMENT(PointBIndex,PointBLevel,PointCIndex,PointCLevel)coloured(255,10,10) style(line)DRAWSEGMENT(PointAIndex,PointALevel,PointBIndex,PointBLevel)coloured(255,10,10) style(line)elseABCD = 0endifendifnextnextendifreturn ABCD COLOURED(0, 255, 0) STYLE(histogram) as "Bearish ABCD"The only version that gets close to resembling what I’m looking for is this:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071// https://www.prorealcode.com/TOPic/array-variables-availability-in-prorealtime/// (please do not remove the link above for future reference)// Example #6: flat base triangle or double TOP/bottomdefparam calculateonlastbars=500// defparam drawonlastbaronly=false// --- settingsfractalP = 10 // fractal periodbarlimit = 100 // maximum no. of bars between points B and D of ABCD pattern// --- end of settings//fractalscp = fractalPif high[cp] >= highest[(cp)*2+1](high) then //new fractal high found$TOPy[lastset($TOPy)+1] = high[cp] //store fractal value$TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindexendif// if low[cp] <= lowest[(cp)*2+1](low) then //new fractal low found// $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value// $BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindex// endifif(islastbarupdate and isset($TOPy[0])) then // and isset($boty[0])//check points in a range of X percentfor i = 0 to lastset($TOPy) do //loop through the TOPsfor y = 0 to lastset($TOPy) do //check first TOP with other TOPschange = abs(($TOPy[y]-$TOPy[i])/$TOPy[i]) //percent range between the 2 TOPsbardiff = abs($TOPx[i]-$TOPx[y]) //how many bars between the 2 points?if change >= percent/100 and bardiff >= fractalP and bardiff < barlimit and $TOPx[i] <> $TOPx[y] thenPointDLevel = max($TOPy[i],$TOPy[y])PointDIndex = max($TOPx[i],$TOPx[y])PointBLevel = min($TOPy[i],$TOPy[y])PointBIndex = min($TOPx[i],$TOPx[y])PointCLevel = lowest[bardiff](low)[barindex-PointDIndex]PointCIndex = 0for a = 0 to bardiff doif low[a+(barindex-PointDIndex)] = PointCLevel thenPointCIndex = PointDIndex-abreakendifnextbardiffPointCtoD = PointDIndex-PointCIndex// PointALevel = 0// PointAIndex = 0// for b = -barsmarginerror to barsmarginerror do// if low[(barindex-PointBIndex)+bardiffPointCtoD+b] = lowest[bardiffPointCtoD+b+cp](low)[barindex-PointBIndex] then// PointALevel = low[(barindex-PointBIndex)+bardiffPointCtoD+b]// PointAIndex = PointBIndex-bardiffPointCtoD-b// break// endif// next// if (PointBLevel-PointCLevel) >= (Fibthreshold1*(PointBLevel-PointALevel)) and (PointBLevel-PointCLevel) >= (Fibthreshold2*(PointBLevel-PointALevel)) then// ABCD = 1// DRAWSEGMENT($TOPx[i],$TOPy[i],$TOPx[y],$TOPy[y])coloured(255,10,10) style(line,3)DRAWSEGMENT(PointCIndex,PointCLevel,PointDIndex,PointDLevel)coloured(255,10,10) style(line,3)DRAWSEGMENT(PointBIndex,PointBLevel,PointCIndex,PointCLevel)coloured(10,10,255) style(line,3)// DRAWSEGMENT(PointAIndex,PointALevel,PointBIndex,PointBLevel)coloured(0,255,0) style(line,3)// else// ABCD = 0// endifendifnextnextendifreturnbut then take a look at this….
Oops…
I suspect one has to use zig zags as opposed to pivots in arrays – at least that’s what harmonic indicators on other platforms seem to use. Anyway, I’m at the limit of my coding ability here, but I’ve tried not to cause annoyance by simply coming on here and asking straight up if someone can just do it for me…
I know there is a harmonic collection available on the Marketplace courtesy of Ale, but I’m not ready to spend EUR200+ without a trial first. Plus I’m only really looking for ABCDs – I can dispense with the other patterns for now. Surely ABCDs can be made available open source…?
Thanks in advance for your help,
JM
04/06/2022 at 1:59 AM #191294Arrays make it easier to store multiple patterns to be plotted, but they do not provide any help in coding the pattern.
When I wrote it, it took me so long that I swore to myself that I wouldn’t approach harmonic patterns any more!
1 user thanked author for this post.
04/06/2022 at 9:07 AM #191309OK thanks, Roberto. I wonder how Alessandro from Automatic Trading has done it…
https://market.prorealcode.com/product/eurhythmic-patterns-v11/
04/06/2022 at 9:31 AM #191314Apart from fancier graphics, anyone who wants to code harmonic patterns has to detect all involved points doing all required calculations, then plot it when the pattern is complete.
Instructions are the same for everybody, what’s different is the use anyone can do of them, but here’s not much to be done differently.
Coding harmonic patterns is not an easy task. -
AuthorPosts