RicardoSantos

[RS]Fractals V5

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)

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
응답
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 응답
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 하우스룰(내부규정) 모더레이터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 Help Center 기능 개발/개선 요청 블로그 & 뉴스 잦은물음 위키 트위터
프로화일 프로화일설정 계정 및 빌링 트레이딩뷰 코인 나의 서포트 티켓 Help Center 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃