RicardoSantos

[RS]Fractal Pattern Recognition V0

EXPERIMENTAL: reads the rates for the last top/bottom in a zigzag fractal series, outputs XAB, XAD, ABC , and BCD rates, im interested in earing what your opinion is as im a total noob in harmonics :p.

use with Fractals V5 for visual confirmation ;).
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
study(title="[RS]Fractal Pattern Recognition V0", overlay=false)
//  ||---   Fractal Recognition:
filterBW = input(true, title="filter Bill Williams Fractals:")
filterFractals = input(false, title="Filter fractals using extreme method:")
length = input(24, title="Extreme Window:")

regulartopfractal = high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0]
regularbotfractal = low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0]

billwtopfractal = filterBW ? false : (high[4] < high[2] and high[3] < high[2] and high[2] > high[1] and high[2] > high[0] ? true : false)
billwbotfractal = filterBW ? false : (low[4] > low[2] and low[3] > low[2] and low[2] < low[1] and low[2] < low[0] ? true : false)

ftop = filterBW ? regulartopfractal : regulartopfractal or billwtopfractal
fbot = filterBW ? regularbotfractal : regularbotfractal or billwbotfractal

topf = ftop ? high[2] >= highest(high, length) ? true : false : false
botf = fbot ? low[2] <= lowest(low, length) ? true : false : false

filteredtopf = filterFractals ? topf : ftop
filteredbotf = filterFractals ? botf : fbot
//  ||------------------------------------------------------------------------------------------------------

//plotshape(filteredtopf, style=shape.triangledown, location=location.abovebar, color=red, text="•", offset=-2)
//plotshape(filteredbotf, style=shape.triangleup, location=location.belowbar, color=lime, text="•", offset=-2)
//  ||---   V1 : Added Swing High/Low Option
//ShowSwingsHL = input(true)
//highswings = filteredtopf == false ? na : valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf == true, high[2], 1) and valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf == true, high[2], 0)
//lowswings = filteredbotf == false ? na : valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf == true, low[2], 1) and valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf == true, low[2], 0)
//---------------------------------------------------------------------------------------------------------
//  ||---   Offset calculation:
//  ||--- unable to use, plots cant use series for offset value...
//hsoffset = n-valuewhen(ftop == true, n[2], 1)
//lsoffset = n-valuewhen(fbot == true, n[2], 1)
//---------------------------------------------------------------------------------------------------------
//plotshape(ShowSwingsHL ? highswings : na, style=shape.triangledown, location=location.abovebar, color=maroon, text="H", offset=-2)
//plotshape(ShowSwingsHL ? lowswings : na, style=shape.triangleup, location=location.belowbar, color=green, text="L", offset=-2)
//  ||---   V2 : Plot Lines based on the fractals.
//showchannel = input(true)
//plot(showchannel ? (filteredtopf ? high[2] : na) : na, color=black, offset=-2)
//plot(showchannel ? (filteredbotf ? low[2] : na) : na, color=black, offset=-2)
//---------------------------------------------------------------------------------------------------------
//  ||---   HLswings channel: unable to offset values
//plot(showchannel ? (highswings ? high[2] : na) : na, color=black, offset=-2)
//plot(showchannel ? (lowswings ? low[2] : na) : na, color=black, offset=-2)
//----------------------------------------------------------------------------------------------------------
//  ||---   ZigZag:
//showZigZag = input(true)


istop = filteredtopf ? true : false
isbot = filteredbotf ? true : false
topcount = barssince(istop)
botcount = barssince(isbot)

zigzag = (
        istop and topcount[1] > botcount[1] ? high[2] :
        isbot and topcount[1] < botcount[1] ? low[2] :
        na )
//zigzag = not showZigZag ? na : ( filteredtopf == true ? high[2] : filteredbotf == true ? low[2] : na )
//plot(zigzag, color=black, offset=-2)

//  ||---   Pattern Recognition:


//istop() => zigzag == filteredtopf
//isbot() => zigzag == filteredbotf

x = valuewhen(zigzag, zigzag, 4) 
a = valuewhen(zigzag, zigzag, 3) 
b = valuewhen(zigzag, zigzag, 2) 
c = valuewhen(zigzag, zigzag, 1) 
d = valuewhen(zigzag, zigzag, 0)

xab = (abs(b-a)/abs(x-a))
xad = (abs(a-d)/abs(x-a))
abc = (abs(b-c)/abs(a-b))
bcd = (abs(c-d)/abs(b-c))

plot(xab, color=xab != xab[1] ? na : gray, offset=-2)
plot(xad, color=xad != xad[1] ? na : black, offset=-2)
plot(abc, color=abc != abc[1] ? na : teal, offset=-2)
plot(bcd, color=bcd != bcd[1] ? na : olive, offset=-2)

plotshape(xab != xab[1] ? xab : na, text="XAB", color=gray, location=location.absolute, offset=-2)
plotshape(xad != xad[1] ? xad : na, text="XAD", color=black, location=location.absolute, offset=-2)
plotshape(abc != abc[1] ? abc : na, text="ABC", color=teal, location=location.absolute, offset=-2)
plotshape(bcd != bcd[1] ? bcd : na, text="BCD", color=olive, location=location.absolute, offset=-2)

//bgcolor(xd <= 0.8 and xd >= 0.6 ? black : na, transp=25)
//plot(topcounter, color=green, offset=-2)
//plot(botcounter, color=red, offset=-2)

Bình luận

I would love to tell you if it works well but could you please explain in details how it works ?
+4 Phản hồi
What kind of Harmonics you are trying to convey here (Gartley, Bat, Cypher, Crab? )
+1 Phản hồi
this only reads the rates between swings in the zigzag (pattern independent).
+1 Phản hồi
is this code valid for MT4 ? if not , for which trading station is valid ?
Phản hồi
it gives the % rates for the last tops/bottoms in a fractal zigzag () for xabcd format interpretation, granted its a bit blunt visually. its mainly a case study slash method for further interpretation of patterns
Phản hồi
Bastioun RicardoSantos
Thank you for your answer. I am sorry but I am not an english spoken person so I hardly understand what you just said
Phản hồi