简体   繁体   中英

Pine script version 2 to 4 conversion identifier error

I am trying to convert the below syntax from pine version2 to version4 but it gives me an Undeclared identifier error as:

"line 17: Undeclared identifier 'ND_stretch'" and so for other ND related lines

The script is as below. Please help me with the fix. Thank you in advance for your time and help.

//@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)
//@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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM