ABCD Pattern with Fib Levels
Forums › ProRealTime English forum › ProBuilder support › ABCD Pattern with Fib Levels
- This topic has 0 replies, 1 voice, and was last updated 4 years ago by tobytarczy.
-
-
06/15/2020 at 9:49 AM #135357
I have taken the Pattern Armonici ABCD code and modified it to work with an ABCD pattern that I have been working with on MT4, (hate MT4). I am not a coder, but I can be dangerous. I have re-worked the logic such that the Fib levels go from 0% to 200%, which have been coloured coded.
I am now looking to expand the functionality to include the next letter “C” and subsequently the letter “D”.
I am using the current allocation of “A” and “B” as per the code. I would like to now add point “C”, where it is the next low point or high point after point “B” which should be anywhere between 38.7% and 78.6% Fib levels. Point “D” would then be projected above or below the 100% Fib level into the corresponding colour Zone. I would include a 2-5% tolerance with point “C” in determining a Fib level to project above or below the 100% level in establishing the Point D.
Finally once point “C” is determined then point “D” would be a projection into the Fib level greater than 100% into the corresponding colour, eg. yellow to yellow, orange to orange, and red to red. I am not concerned about the purple zone or the grey zone above.
I am sure that my code could be greatly improved upon, and any suggestions would be greatly appreciated. For now I am looking for help to establish point “C” and subsequently point “D”.
Many thanks in advance.
Here is the code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303//PRC_Quick Fib | indicator//09.01.2019//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledgedefparam drawonlastbaronly = true// --- settingsperiod = period //lookback period of the Fibonacci RetracementDrawRetracementBlocks = 1 // 0=false ; 1=true//Drawrectangle = 1// --- end of settingshh=0ll=lowshiftlowest=barindexfibext = FibExtlabeloffset = LabelOffsetFill = ColoursText = FibLevelsLevels = ChartLevels//FibLabel= startbar + fibextfor i = period downto 1 doif high[i]>hh thenhh=high[i]shifthighest=barindex[i]endifif low[i]<ll thenll=low[i]shiftlowest=barindex[i]endifnextisSwingDown = shiftHighest < shiftLowestif isSwingDown thenfullrange = abs(hh-ll)fibo100 = llfibo0 = hhfibo236 = hh-(fullrange*0.236)fibo382 = hh-(fullrange*0.382)fibo50 = hh-fullrange/2fibo618 = hh-(fullrange*0.618)fibo70 = hh-(fullrange*0.700)fibo786 = hh-(fullrange*0.786)fibo886 = hh-(fullrange*0.886)fibo118 = hh-(fullrange*1.18)fibo1272 = hh-(fullrange*1.272)fibo144 = hh-(fullrange*1.44)fibo1618 = hh-(fullrange*1.618)fibo200 = hh-(fullrange*2.00)startbar = min(shifthighest,shiftlowest)r=255g=0b=0elsefullrange = abs(hh-ll)fibo100 = hhfibo0 = llfibo236 = ll+(fullrange*0.236)fibo382 = ll+(fullrange*0.382)fibo50 = hh-fullrange/2fibo618 = ll+(fullrange*0.618)fibo70 = ll+(fullrange*0.700)fibo786 = ll+(fullrange*0.786)fibo886 = ll+(fullrange*0.886)fibo118 = ll+(fullrange*1.18)fibo1272 = ll+(fullrange*1.272)fibo144 = ll+(fullrange*1.44)fibo1618 = ll+(fullrange*1.618)fibo200 = ll+(fullrange*2.00)startbar = min(shifthighest,shiftlowest)r=0g=255b=0endifif startbar>0 then//plot fibonacci levelsdrawsegment(startbar + 2,fibo100,startbar + fibext,fibo100) coloured(0,0,0) style(dottedline,2)if text = 1 thendrawtext("100.0%",Startbar + fibext + labeloffset,fibo100,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#hh#",Startbar + fibext + labeloffset +8,fibo100,Dialog,Standard,10) coloured(0,0,0)endifif Fill =1 thendrawrectangle(startbar + 2, fibo100, startbar + fibext, fibo118) coloured(255,255,0,80) bordercolor(255,255,255,0)endifdrawsegment(startbar +2,fibo0,startbar + fibext,fibo0) coloured(0,0,0) style(dottedline,2)if Fill =1 thendrawrectangle(startbar + 2, fibo0, startbar + fibext, fibo382) coloured(224,224,224,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext(" 0.0%",Startbar + fibext + labeloffset,fibo0,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#ll#",Startbar + fibext + labeloffset +8,fibo0,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo236,startbar + fibext,fibo236) coloured(128,128,128)if text = 1 thendrawtext(" 23.6%",Startbar + fibext + labeloffset,fibo236,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo236#",Startbar + fibext + labeloffset +8,fibo236,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo382,startbar + fibext,fibo382) coloured(255,255,0,0)if Fill =1 thendrawrectangle(startbar + 2, fibo382, startbar + fibext, fibo50) coloured(255,255,0,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext(" 38.2%",Startbar + fibext + labeloffset,fibo382,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo382#",Startbar + fibext + labeloffset +8,fibo382,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo50,startbar + fibext,fibo50) coloured(153,0,0)if Fill =1 thendrawrectangle(startbar + 2, fibo50, startbar + fibext, fibo70) coloured(153,0,0,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext(" 50.0%",Startbar + fibext + labeloffset,fibo50,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo50#",Startbar + fibext + labeloffset +8,fibo50,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo618,startbar + fibext,fibo618) coloured(153,0,0)//drawrectangle(startbar + 2, fibo618, startbar + fibext, fibo786) coloured(153,0,0,80) bordercolor(255,255,255,0)if text = 1 thendrawtext("61.8%",Startbar + fibext + labeloffset,fibo618,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo618#",Startbar + fibext + labeloffset+8,fibo618,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo70,startbar + fibext,fibo70) coloured(255,128,0)if Fill =1 thendrawrectangle(startbar + 2, fibo70, startbar + fibext, fibo786) coloured(255,128,0,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext("70.0%",Startbar + fibext +labeloffset,fibo70,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo70#",Startbar + fibext + labeloffset +8,fibo70,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo786,startbar + fibext,fibo786) coloured(160,160,160)if Fill =1 thendrawrectangle(startbar + 2, fibo786, startbar + fibext, fibo100) coloured(160,160,160,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext("78.6%",Startbar + fibext + labeloffset,fibo786,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo786#",Startbar + fibext + labeloffset +8,fibo786,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo886,startbar + fibext,fibo886) coloured(128,128,128)//drawrectangle(startbar + 2, fibo886, startbar + fibext, fibo100) coloured(153,153,0,80) bordercolor(255,255,255,0)if text = 1 thendrawtext("88.6%",Startbar + fibext + labeloffset,fibo886,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo886#",Startbar + fibext + labeloffset +8,fibo886,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo118,startbar + fibext,fibo118) coloured(255,128,0)if Fill =1 thendrawrectangle(startbar + 2, fibo118, startbar + fibext, fibo1272) coloured(255,128,0,80)bordercolor(255,255,255,0)endifif text = 1 thendrawtext("118.0%",Startbar + fibext + labeloffset,fibo118,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo118#",Startbar + fibext + labeloffset +8,fibo118,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo1272,startbar + fibext,fibo1272) coloured(153,0,0)if Fill =1 thendrawrectangle(startbar + 2, fibo1272, startbar + fibext, fibo144) coloured(153,0,0,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext("127.2%",Startbar + fibext + labeloffset,fibo1272,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo1272#",Startbar + fibext + labeloffset +8,fibo1272,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo144,startbar + fibext,fibo144) coloured(153,0,153)if Fill =1 thendrawrectangle(startbar + 2, fibo144, startbar + fibext, fibo1618) coloured(153,0,153,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext("144.0%",Startbar + fibext + labeloffset,fibo144,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo144#",Startbar + fibext + labeloffset +8,fibo144,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo1618,startbar + fibext,fibo1618) coloured(204,229,255)if Fill =1 thendrawrectangle(startbar + 2, fibo1618, startbar + fibext, fibo200) coloured(204,229,255,80) bordercolor(255,255,255,0)endifif text = 1 thendrawtext("161.8%",Startbar + fibext + labeloffset,fibo1618,Dialog,Standard,10) coloured(0,0,0)endifif levels = 1 thendrawtext("#fibo1618#",Startbar + fibext + labeloffset +8,fibo1618,Dialog,Standard,10) coloured(0,0,0)endifdrawsegment(startbar +2,fibo200,startbar + fibext,fibo200) coloured(0,0,0) style(dottedline, 2)if text = 1 thendrawtext("200.0%",Startbar + fibext + labeloffset,fibo200,Dialog,Standard,10) coloured(0,0,0)if levels = 1 thendrawtext("#fibo200#",Startbar + fibext + labeloffset +8,fibo200,Dialog,Standard,10) coloured(0,0,0)endifendif//plot price at 0% and 100% levelsif fibo0=ll thendrawtext("A",shiftlowest,ll-fullrange*0.03,dialog,bold,15) coloured(r,g,b)elsedrawtext("B",shiftlowest,ll-fullrange*0.03,dialog,bold,15) coloured(r,g,b)endif//drawtext("#ll#",shiftlowest,ll-fullrange*0.03,dialog,bold,15) coloured(0,255,0)if fibo0=hh thendrawtext("A",shifthighest,hh+fullrange*0.03,dialog,bold,15) coloured(r,g,b)elsedrawtext("B",shifthighest,hh+fullrange*0.03,dialog,bold,15) coloured(r,g,b)endif//drawtext("#hh#",shiftlowest,ll-fullrange*0.03,dialog,bold,15) coloured(0,255,0)endifif fibo0=ll thendrawsegment(Startbar, fibo0, shifthighest, hh) coloured(0,0,255) style(dottedline, 2)elseif fibo0=hh thendrawsegment(Startbar, fibo0, shiftlowest, ll) coloured(0,0,255) style(dottedline, 2)endifendif//if fibo0 =1 and fibo0=ll then//drawsegment( shifthightes, hh,//contour linesshiftContourDown = barindex-shiftHighesthighestSlope = 0counth=max(1,(barindex-shifthighest))for i = 2 to counth dothisSlope = (High[i] - hh) / ((barindex-shiftHighest) - i)if (thisSlope >= highestSlope or highestSlope = 0) thenshiftContourDown = ihighestSlope = thisSlopeendifnextshiftContourUp = barindex-shiftLowestLowestSlope = 0countl=max(1,(barindex-shiftLowest))for i = 2 to countl dothisSlope = (low[i] - ll) / ((barindex-shiftLowest) - i)if (thisSlope <= LowestSlope or LowestSlope = 0) thenshiftContourUp = iLowestSlope = thisSlopeendifnext//drawline(shifthighest,hh,barindex[shiftcontourdown],high[shiftcontourdown]) coloured(r,g,b)//drawline(shiftlowest,ll,barindex[shiftcontourup],low[shiftcontourup]) coloured(r,g,b)//retracement blocks//if DrawRetracementBlocks then//if not isSwingDown then//blockprice=hh//startbar=barindex-shifthighest//for i = startbar downto 2 do//if low[i]<blockprice then//blockprice=low[i]//blockbar=barindex[i]//endif//next//drawrectangle(blockbar,blockprice,barindex,ll) coloured(r,g,b)//else//blockprice=ll//startbar=barindex-shiftlowest//for i = startbar downto 2 do//if high[i]>blockprice then//blockprice=high[i]//blockbar=barindex[i]//endif//next//drawrectangle(blockbar,blockprice,barindex,hh) coloured(r,g,b)//endif//endifreturn -
AuthorPosts
Find exclusive trading pro-tools on