如何将 pinescript 从 v2 转换为 v4?

时间:2021-04-09 21:41:52

标签: pine-script indicator

我从交易视图中获得了这个脚本,我想在我的策略中使用它,但它在 v2 中。我需要帮助将其更改为 v4。谢谢大家。

study("Kuskus Starlight", overlay=false)
//parameters
range = input (30, title="Range Periods")
pricesmoothing = input(0.3, title = "Price Smoothing")
indexsmoothing = input(0.3, title = "Index Smoothing")

highesthigh = highest(high, range)
lowestlow = lowest(low, range)

greatestrange = (highesthigh - lowestlow)!=0?(highesthigh-lowestlow):greatestrange[1]
midprice = (high+low)/2

//pricelocation
pricelocation = 2*((midprice-lowestlow)/greatestrange)-1

//smoothing of pricelocation
extmapbuffer = pricesmoothing*nz(extmapbuffer [1]) + (1-pricesmoothing)*pricelocation
smoothedlocation = (extmapbuffer>0.99?0.99:(extmapbuffer<-0.99?-0.99:extmapbuffer))!=1?(extmapbuffer>0.99?0.99:(extmapbuffer<-0.99?-0.99: extmapbuffer)): smoothedlocation [1]

//Fisher location
fishindex = log((1+smoothedlocation)/(1-smoothedlocation))

//smoothingoffishindex
extmapbuffer1 = indexsmoothing*nz(extmapbuffer1[1])+(1-indexsmoothing)*(fishindex)
smoothedfish = extmapbuffer1

plot(smoothedfish, color=smoothedfish>0?green:red, linewidth=3, style=histogram)

0 个答案:

没有答案