【问题标题】:Pine script version 2 to 4 conversion identifier errorPine 脚本版本 2 到 4 转换标识符错误
【发布时间】:2021-02-13 08:55:20
【问题描述】:

我正在尝试将以下语法从 pine version2 转换为 version4,但它给了我一个未声明的标识符错误:

"line 17: Undeclared identifier 'ND_stretch'" 其他 ND 相关行

脚本如下。请帮我修复。提前感谢您的时间和帮助。

//@version=4 study(title='[JK]MY Own ORB V1', shorttitle='ORB', overlay=true)

//  Request for DCC

mode = input(title='Mode (1:timeframe, 2:session):', type=input.integer, minval=1, maxval=2, defval=1) tf = input(title='Timeframe for open range:', type=input.string, defval='60', confirm=false) tf2 = input(title='Timeframe for range capture:', type=input.string, defval='D', confirm=false) sess = input(title='Session for mode 2:', type=input.string, defval='0400-1500')

f_is_new_day(_mode) => _mode == 1 ? change(time(tf2))!=0 : _mode == 2 ? change(time(tf2, sess))!=0 : false

ND_open = f_is_new_day(mode) ? security(syminfo.tickerid, tf, open) : ND_open[1]

ND_high = f_is_new_day(mode) ? security(syminfo.tickerid, tf, high) : ND_high[1]

ND_low = f_is_new_day(mode) ? security(syminfo.tickerid, tf, low) : ND_low[1]

ND_stretch = na(ND_stretch[1]) ? 0 : f_is_new_day(mode) ? (ND_stretch[1]*9 + security(syminfo.tickerid, tf, (high-open)>=(open-low)?high-open:open-low)) / 10 : ND_stretch[1]

filter_high = f_is_new_day(mode) ? na : ND_high

filter_low = f_is_new_day(mode) ? na : ND_low

filter_high_stretch = f_is_new_day(mode) ? na : ND_high+ND_stretch

filter_low_stretch = f_is_new_day(mode) ? na : ND_low-ND_stretch //style = line.style_solid

fh = plot(title='TR', series=filter_high, style=line.style_solid, color=color.black)

fl = plot(title='BR', series=filter_low, style=line.style_solid, color=color.black)

fhs = plot(title='TS', series=filter_high_stretch, style=line.style_solid, color=color.green)

fls = plot(title='BS', series=filter_low_stretch, style=line.style_solid, color=color.maroon)

fill(title='Positive Stretch', plot1=fh, plot2=fhs, color=color.green, transp=50)

fill(title='Negative Stretch', plot1=fl, plot2=fls, color=color.maroon, transp=50)

【问题讨论】:

    标签: pine-script


    【解决方案1】:
    //@version=4 
    study(title='Help ([JK]MY Own ORB V1)', shorttitle='ORB', overlay=true)
    
    // Request for DCC
    
    mode = input(title='Mode (1:timeframe, 2:session):', type=input.integer, minval=1, maxval=2, defval=1) 
    tf = input(title='Timeframe for open range:', type=input.string, defval='60', confirm=false) 
    tf2 = input(title='Timeframe for range capture:', type=input.string, defval='D', confirm=false) 
    sess = input(title='Session for mode 2:', type=input.string, defval='0400-1500')
    
    f_is_new_day(_mode) => _mode == 1 ? change(time(tf2))!=0 : _mode == 2 ? change(time(tf2, sess))!=0 : false
    
    ND_open = 0.0
    ND_open := f_is_new_day(mode) ? security(syminfo.tickerid, tf, open) : ND_open[1]
    
    ND_high = 0.0
    ND_high := f_is_new_day(mode) ? security(syminfo.tickerid, tf, high) : ND_high[1]
    
    ND_low = 0.0
    ND_low := f_is_new_day(mode) ? security(syminfo.tickerid, tf, low) : ND_low[1]
    
    ND_stretch = 0.0
    ND_stretch := na(ND_stretch[1]) ? 0 : f_is_new_day(mode) ? (ND_stretch[1]*9 + security(syminfo.tickerid, tf, (high-open)>=(open-low)?high-open:open-low)) / 10 : ND_stretch[1]
    
    filter_high = f_is_new_day(mode) ? na : ND_high
    
    filter_low = f_is_new_day(mode) ? na : ND_low
    
    filter_high_stretch = f_is_new_day(mode) ? na : ND_high+ND_stretch
    
    filter_low_stretch = f_is_new_day(mode) ? na : ND_low-ND_stretch //style = line.style_solid
    
    fh = plot(title='TR', series=filter_high, style=plot.style_line, color=color.black)
    
    fl = plot(title='BR', series=filter_low, style=plot.style_line, color=color.black)
    
    fhs = plot(title='TS', series=filter_high_stretch, style=plot.style_line, color=color.green)
    
    fls = plot(title='BS', series=filter_low_stretch, style=plot.style_line, color=color.maroon)
    
    fill(title='Positive Stretch', plot1=fh, plot2=fhs, color=color.green, transp=50)
    
    fill(title='Negative Stretch', plot1=fl, plot2=fls, color=color.maroon, transp=50)
    

    【讨论】:

    • 如果您的答案是完整的,请使用article 的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-11
    • 2020-12-11
    • 1970-01-01
    • 2022-10-15
    相关资源
    最近更新 更多