RicardoSantos

[RS]Fractals V5

9179 lượt xem
1862
9179 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.
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
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
Phản hồi
@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
Phản hồi
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 Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Shows Cách thức hoạt động Tính năng Biểu đồ Giá Quy tắc Áp dụng Người điều hành Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Trung tâm Trợ giúp Giới thiệu bạn Yêu cầu tính năng Blog & Tin tức Câu hỏi thường gặp Wiki Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất