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 ;).
Remove from Favorite Scripts Add to Favorite Scripts
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)
is this code valid for MT4 ? if not , for which trading station is valid ?
Reply
What kind of Harmonics you are trying to convey here (Gartley, Bat, Cypher, Crab? )
Reply
this only reads the rates between swings in the zigzag (pattern independent).
+1 Reply
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
Reply
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
Reply
I would love to tell you if it works well but could you please explain in details how it works ?
Reply
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out