RicardoSantos

[RS]Fractals V5

צפיות ‎9795‎
1938
9795 3
Update to the zigzag , now it ignores the second top/bottom untill it finds a inversed top/bottom. TBTBTBTBTBTBTB instead of TBBTTBTBBTBTTB.

Updated to V8, link bellow in the related ideas.
הסר מסקריפטים מועדפים הוסף לסקריפטים מועדפים
study(title="[RS]Fractals V5", overlay=true)
//  ||---   V1: Added filtering option
//  ||---   V4: diferentiated Bill Williams fractals and regular fractals as a choice
//  ||---       added zigzag option
//  ||---   V5: modified zigzag
//  ||---   Fractal Recognition:
filterBW = input(false, 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 = not showZigZag ? na : (
        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)

תגובות

LuckyMouse asked:
'Hi Ricardo - been looking again at FractalsV5 - ShowSwingHL feature - looks fantastic with labels option - but often flags late on the peak after the main swingHL peak. Couldnt understand the pinescript at all so dont know how it works? It would be cool and maybe profitable if i could understand how its calculated (logic wise) and maybe collaborate on poss new techniques to flag it at the extremes? Any chance you can explain concept and rational. Im a spreadsheet developer in finance and into various TA so understand most concepts. Bests LM'

the delay is caused by the need for confirmation of the fractal pattern as it needs to wait for the next 2 candles after the top/bottom to confirm that we have a extreme.
there is also another issue due to pinescript currently not having looping capability s:
• its not possible to change a lower top for the next when 2 top or 2bottoms form in a row and the second is higher/lower then the previous.

+10 השב
great stuff, would you be able to add ratio between two adjacent legs? like retracement %.

tks
השב
@jacxia81, its possible only as a numeric variable plot (it shows after the indicators name on the top left of the chart), or another indicator just for that purpose
השב
בית סורק מניות סורק מט"ח סורק מטבעות-קריפטו יומן כלכלי איך זה עובד‏ תכונות גרף מחירון הפנה חבר חוקי הבית מרכז תמיכה כלים לאתרים וברוקרים יישומונים פתרונות גרפיים ספריית גרפים קלי משקל בלוג וחדשות טוויטר‏
פרופיל הגדרות פרופיל חשבון וחיוב הפנה חבר לשוניות התמיכה שלי מרכז תמיכה רעיונות שפורסמו עוקבים עוקב אחרי... הודעות פרטיות צ'אט התנתק