0

下面代码中的研究有效。我可以在收盘价/股票收盘价的上方和下方打印两条水平斐波那契线。

但是,当数字 > 34000 或股票代码值较大时;“for 循环”似乎会产生延迟,然后交易视图会因为这种延迟而关闭指标。我怎样才能避免这种情况?

//FIBONACCI
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//@version=4
study("Levels_11", overlay=true ) //, max_bars_back = 5000    )

var  int fib_counter_a = 0
var  int fib_counter_b = fib_counter_a + 1
var  int fib_counter_c = 0

//if(fib_counter_c <= close_timeframe )

if ((close_timeframe >  min_acceptable_close_value_line_value_end_fib) and  show_line_value_end_fib   )
    for line_value_end_fib = 1 to close_timeframe   
        if(fib_counter_c <= close_timeframe )
            fib_counter_a   :=   fib_counter_b
            fib_counter_b   :=   fib_counter_c
            fib_counter_c   :=   fib_counter_a + fib_counter_b
        plot_fib = ( abs(fib_counter_c - close_timeframe) >= abs(fib_counter_b - close_timeframe) ? fib_counter_b : fib_counter_c )
        
        line.new(x1 = time, y1 = fib_counter_b,     x2 = time+1, y2 = fib_counter_b,    xloc = xloc.bar_time, extend=extend.both,   style= line_Style_fib_var, color = Color_Brightness_fib, width = line_Thickness_fib)
        line.new(x1 = time, y1 = fib_counter_c,     x2 = time+1, y2 = fib_counter_c,    xloc = xloc.bar_time, extend=extend.both,   style= line_Style_fib_var, color = Color_Brightness_fib, width = line_Thickness_fib)


//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// LINE IS A FIBONACCI NUMBER // 
//END
4

0 回答 0