0

我一直在尝试找到一种方法来自动在我所在时间框架的开盘柱上绘制斐波那契回撤,同时在前 30 分钟将其向右延伸。尝试修改了几个代码,但只设法让它在第一个栏上设置 fib,但不知道如何让它向右延伸并在 30 分钟后将其切断。从我在这里所做的所有研究中,似乎答案可能在于使用线条,但经过数小时的沮丧尝试后,我不明白如何将其用于 fibs。这是我所拥有的最接近我想要的代码。对不起,如果代码有不必要的部分,我对编码很陌生!任何帮助是极大的赞赏!

//@version=4
study(title='opening fib', overlay=true)

timeframe = input('5', "Timeframe", input.resolution)
d_shift = -0
sessSpec = input("0930-1000", type=input.session)

is_newbar(res, sess) =>
    t = time(res, sess)
    na(t[1]) and not na(t) or t[1] < t

newbar = is_newbar("1440", sessSpec)

var float s1 = na
var float s2 = na
var float s3 = na
var float s4 = na
if newbar
    s1 := low
    s2 := high
    s3 := open
    s4 := close

disp_f1 = input(true, title="236")
F1 = input(0.236, type=input.float)
disp_f2 = input(true, title="382")
F2 = input(0.382, type=input.float)
disp_f3 = input(true, title="50")
F3 = input(0.5, type=input.float)
disp_f4 = input(true, title="618")
F4 = input(0.618, type=input.float)
disp_f5 = input(true, title="-10")
F5 = input(-0.1, type=input.float)
disp_f6 = input(true, title="-15")
F6 = input(-0.15, type=input.float)
disp_f7 = input(true, title="-20")
F7 = input(-0.2, type=input.float)

fibrange = s2 - s1
if s4 >= s3
    F1 := s2 - F1 * abs(fibrange)
    F2 := s2 - F2 * abs(fibrange)
    F3 := s2 - F3 * abs(fibrange)
    F4 := s2 - F4 * abs(fibrange)
    F5 := s2 - F5 * abs(fibrange)
    F6 := s2 - F6 * abs(fibrange)
    F7 := s2 - F7 * abs(fibrange)
else
    F1 := s1 + F1 * abs(fibrange)
    F2 := s1 + F2 * abs(fibrange)
    F3 := s1 + F3 * abs(fibrange)
    F4 := s1 + F4 * abs(fibrange)
    F5 := s1 + F5 * abs(fibrange)
    F6 := s1 + F6 * abs(fibrange)
    F7 := s1 + F7 * abs(fibrange)
    

r_R1 = plot(title='-20', series=F7, offset=d_shift, color=color.red, style=plot.style_line, linewidth=1)
r_R2 = plot(title='-15', series=F6, offset=d_shift, color=#1e90ff, style=plot.style_cross, linewidth=1)
r_R3 = plot(title='-10', series=F5, offset=d_shift, color=color.green, style=plot.style_line, linewidth=1)
r_s2 = plot(title='high', series=s2, offset=d_shift, color=color.green, style=plot.style_line, linewidth=1)
r_R4 = plot(title='236', series=F1, offset=d_shift, color=#00bfff, style=plot.style_cross, linewidth=1)
r_R5 = plot(title='382', series=F2, offset=d_shift, color=color.red, style=plot.style_line, linewidth=1)
r_R6 = plot(title='50', series=F3, offset=d_shift, color=color.black, style=plot.style_line, linewidth=2)
r_R7 = plot(title='618', series=F4, offset=d_shift, color=color.green, style=plot.style_cross, linewidth=1)
r_s1 = plot(title='low', series=s1, offset=d_shift, color=color.red, style=plot.style_line, linewidth=1)

4

0 回答 0