커뮤니티

수식 변경 요청 드립니다.

프로필 이미지
졸던
2026-02-26 14:38:34
121
글번호 230802
답변완료

트레이딩뷰의 수식 입니다.''

예스차트에 적용 할수 있도록 수정 바랍니다.

----------------------------------------------------------------------------------


//@version=5

indicator("Real-Time Fibonacci Levels", overlay=true)



showTodayLabels = input.bool(false, title="Show Today High/Low Labels")



labelSize = input.string("small", options=["small", "normal", "large"], title="Label Size")

labelColor = input.color(color.new(color.blue, 50), title="Label Color")


var float todayLow = na

var float todayHigh = na

var float fibHigh = na

var float fibLow = na

var float tempHigh = na

var float tempLow = na

var array<label> fibLabels = na

if na(fibLabels)

    fibLabels := array.new_label(7)



newDay = (dayofweek != dayofweek[1])

if (newDay)

    todayLow := low

    todayHigh := high

    fibHigh := na

    fibLow := na

    tempHigh := na

    tempLow := na


    for i = 0 to array.size(fibLabels) - 1

        label.delete(array.get(fibLabels, i))

    array.clear(fibLabels)



    for i = 0 to 6

        array.push(fibLabels, label.new(na, na, text = '', style = label.style_label_upper_right, color = labelColor, size = labelSize, textcolor = color.white))



if (low < todayLow)

    todayLow := low

    fibLow := todayLow  

    tempHigh := na      


if (high > todayHigh)

    todayHigh := high

    fibHigh := todayHigh

    tempLow := na         



if not na(fibLow) and high > fibLow and (na(tempHigh) or high > tempHigh)

    tempHigh := high


if not na(fibHigh) and low < fibHigh and (na(tempLow) or low < tempLow)

    tempLow := low



activeHigh = na(tempHigh) ? fibHigh : tempHigh

activeLow = na(tempLow) ? fibLow : tempLow



fibLevel1 = activeHigh - (activeHigh - activeLow) * 0.236

fibLevel2 = activeHigh - (activeHigh - activeLow) * 0.382

fibLevel3 = activeHigh - (activeHigh - activeLow) * 0.5

fibLevel4 = activeHigh - (activeHigh - activeLow) * 0.618

fibLevel5 = activeHigh - (activeHigh - activeLow) * 0.764



plot(todayHigh, color=color.green, title="Today's High")

plot(todayLow, color=color.red, title="Today's Low")

plot(activeHigh, color=color.orange, title="Active High")

plot(activeLow, color=color.purple, title="Active Low")

plot(fibLevel1, color=color.blue, title="Fib 23.6%")

plot(fibLevel2, color=color.blue, title="Fib 38.2%")

plot(fibLevel3, color=color.blue, title="Fib 50.0%")

plot(fibLevel4, color=color.blue, title="Fib 61.8%")

plot(fibLevel5, color=color.blue, title="Fib 76.4%")



if array.size(fibLabels) >= 7

    if showTodayLabels

        label.set_xy(array.get(fibLabels, 0), bar_index + 0, todayHigh)

        label.set_text(array.get(fibLabels, 0), "Today High: " + str.tostring(todayHigh, format.mintick))


        label.set_xy(array.get(fibLabels, 1), bar_index + 0, todayLow)

        label.set_text(array.get(fibLabels, 1), "Today Low: " + str.tostring(todayLow, format.mintick))

    else

        label.set_xy(array.get(fibLabels, 0), na, na)

        label.set_text(array.get(fibLabels, 0), "")


        label.set_xy(array.get(fibLabels, 1), na, na)

        label.set_text(array.get(fibLabels, 1), "")


    label.set_xy(array.get(fibLabels, 2), bar_index + 0, fibLevel1)

    label.set_text(array.get(fibLabels, 2), "R7-2 : " + str.tostring(fibLevel1, format.mintick))


    label.set_xy(array.get(fibLabels, 3), bar_index + 0, fibLevel2)

    label.set_text(array.get(fibLabels, 3), "R6-3 : " + str.tostring(fibLevel2, format.mintick))


    label.set_xy(array.get(fibLabels, 4), bar_index + 0, fibLevel3)

    label.set_text(array.get(fibLabels, 4), "R5 : " + str.tostring(fibLevel3, format.mintick))


    label.set_xy(array.get(fibLabels, 5), bar_index + 0, fibLevel4)

    label.set_text(array.get(fibLabels, 5), "R3-6 : " + str.tostring(fibLevel4, format.mintick))


    label.set_xy(array.get(fibLabels, 6), bar_index + 0, fibLevel5)

    label.set_text(array.get(fibLabels, 6), "R2-7 : " + str.tostring(fibLevel5, format.mintick))


지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-03-03 14:40:50

안녕하세요 예스스탁입니다. plot 출력까지만 되게 작성해 드립니다. var : newDay(False); var : todayLow(Nan); var : todayHigh(Nan); var : fibHigh(Nan); var : fibLow(Nan); var : tempHigh(Nan); var : tempLow(Nan); newDay = dayofweek(sDate) != dayofweek(sDate[1]); if (newDay) Then { todayLow = low; todayHigh = high; fibHigh = Nan; fibLow = nan; tempHigh = nan; tempLow = nan; } if (low < todayLow) Then { todayLow = low; fibLow = todayLow; tempHigh = Nan; } if (high > todayHigh) Then { todayHigh = high; fibHigh = todayHigh; tempLow = Nan; } if IsNan(fibLow) == False and high > fibLow and (IsNan(tempHigh) == true or high > tempHigh) Then tempHigh = high; if IsNan(fibHigh) == False and low < fibHigh and (IsNan(tempLow) == true or low < tempLow) Then tempLow = low; var : activeHigh(0),activeLow(0); var : fibLevel1(0),fibLevel2(0),fibLevel3(0),fibLevel4(0),fibLevel5(0); activeHigh = iff(IsNan(tempHigh) == true, fibHigh , tempHigh); activeLow = iff(IsNan(tempLow) == true, fibLow , tempLow); fibLevel1 = activeHigh - (activeHigh - activeLow) * 0.236; fibLevel2 = activeHigh - (activeHigh - activeLow) * 0.382; fibLevel3 = activeHigh - (activeHigh - activeLow) * 0.5; fibLevel4 = activeHigh - (activeHigh - activeLow) * 0.618; fibLevel5 = activeHigh - (activeHigh - activeLow) * 0.764; plot1(todayHigh,"Today's High",Green); plot2(todayLow,"Today's Low",Red); plot3(activeHigh,"Active High",Orange); plot4(activeLow,"Active Low",Purple); plot5(fibLevel1,"Fib 23.6%",Blue); plot6(fibLevel2,"Fib 38.2%",Blue); plot7(fibLevel3,"Fib 50.0%",Blue); plot8(fibLevel4,"Fib 61.8%",Blue); plot9(fibLevel5,"Fib 76.4%",Blue); 즐거운 하루되세요