原创

如何将该 pinescript 代码更改为另一种语言? [关闭]

温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

It will be developed in connection with blockchain transactions using the pinescript code. However, there was a problem in the process of changing to another programming language code.

code pinescript v5

inpFastPeriod   = input.int(defval=12, title="MACD fast period", minval=1) 
inpSlowPeriod   = input.int(defval=26, title="MACD slow period", minval=1) 
inpMacdSignal   = input.int(defval=9, title="Signal period", minval=1) 
// 5
inpSmoothPeriod = input.int(defval=30, title="Smoothing period", minval=1)
// 20
inpNormPeriod   = input.int(defval=30, title="Normalization period", minval=1)
price           = input(close, title="Price Source")
//
emaf = 0.0
emas = 0.0 
val  = 0.0
nval = 0.0
sig  = 0.0
//
red  =color.new(#FF0000, 0)
green=color.new(#32CD32, 0)
black=color.new(#000000, 0)
//
if bar_index > inpSlowPeriod 
    alphaf   = 2.0/(1.0+math.max(inpFastPeriod,1))
    alphas   = 2.0/(1.0+math.max(inpSlowPeriod,1))
    alphasig = 2.0/(1.0+math.max(inpMacdSignal,1))
    alphasm  = 2.0/(1.0+math.max(inpSmoothPeriod,1))
    
    emaf := emaf[1]+alphaf*(price-emaf[1])
    emas := emas[1]+alphas*(price-emas[1])
    imacd = emaf-emas
    
    mmax = ta.highest(imacd,inpNormPeriod)
    mmin = ta.lowest(imacd,inpNormPeriod)
    if mmin != mmax 
        nval := 2.0*(imacd-mmin)/(mmax-mmin)-1.0 
    else
        nval := 0
    
    val := val[1] + alphasm*(nval-val[1])
    sig := sig[1] + alphasig*(val-sig[1])
//
// plot(val, color=val>val[1] ? green:red, style=plot.style_line, linewidth=2, title="Reg smooth MACD")
// plot(sig, color=black, style=plot.style_cross, linewidth=1, title="Signal line")
// hline(0, title='0', color=color.gray, linestyle=hline.style_dotted, linewidth=1)

// =================================================================================

If you look at the code above, imacd = emaf-emas is writing ta.highest, ta.lowest function even though this part is not an array. How should I change it to another programming language?

正文到此结束
热门推荐
本文目录