首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将Pine-Script 2.0版本转换为5.0版本

将Pine-Script 2.0版本转换为5.0版本
EN

Stack Overflow用户
提问于 2022-06-30 08:21:57
回答 1查看 114关注 0票数 -2

我需要帮助把这个指示器从V2转换成V5。这对我来说很复杂。

代码语言:javascript
复制
//@version=2
study("Heiken Ashi MTF")
ha_t = heikinashi(tickerid)

res = input('60', title="TM 1")
ha_open = security(ha_t, res, open)
ha_close = security(ha_t, res, close)
ha_dif = ha_open-ha_close
ha_diff=iff(ha_dif > 0, 1, iff(ha_dif<0, 2, 3))

res2 = input('240', title="TM 2")
ha_open2 = security(ha_t, res2, open)
ha_close2 = security(ha_t, res2, close)
ha_dif2 = ha_open2-ha_close2
ha_diff2=iff(ha_dif2 > 0, 1, iff(ha_dif2<0, 2, 3))

res3 = input('D', title="TM 3")
ha_open3 = security(ha_t, res3, open)
ha_close3 = security(ha_t, res3, close)
ha_dif3 = ha_open3-ha_close3
ha_diff3=iff(ha_dif3 > 0, 1, iff(ha_dif3<0, 2, 3))

plot(15, title="TF1", color=iff(ha_diff==1, red, iff(ha_diff==2, green, white)), style=circles, linewidth=5, join=true)
plot(14, title="TF2", color=iff(ha_diff2==1, red, iff(ha_diff2==2, green, white)), style=circles, linewidth=5, join=true)
plot(13, title="TF3", color=iff(ha_diff3==1, red, iff(ha_diff3==2, green, white)), style=circles, linewidth=5, join=true)

代码是v2,我需要v5。但这太复杂了。我需要一些v5的特性。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-30 09:14:16

代码语言:javascript
复制
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © seriousCockato20483

//@version=5
indicator("Heiken Ashi MTF")
ha_t = ticker.heikinashi(syminfo.tickerid)

res = input('60', title="TM 1")
ha_open = request.security(ha_t, res, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close = request.security(ha_t, res, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif = ha_open-ha_close
ha_diff=ha_dif > 0?  1: (ha_dif<0? 2: 3)

res2 = input('240', title="TM 2")
ha_open2 =  request.security(ha_t, res2, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close2 =  request.security(ha_t, res2, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif2 = ha_open2-ha_close2
ha_diff2=ha_dif2 > 0?  1: (ha_dif2<0? 2: 3)

res3 = input('D', title="TM 3")
ha_open3 =  request.security(ha_t, res3, open, barmerge.gaps_off, barmerge.lookahead_on)
ha_close3 = request.security(ha_t, res3, close, barmerge.gaps_off, barmerge.lookahead_on)
ha_dif3 = ha_open3-ha_close3
ha_diff3=ha_dif3 > 0?  1: (ha_dif3<0? 2: 3)

plot(15, title="TF1", color=ha_diff==1? color.red:(ha_diff==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
plot(14, title="TF2", color=ha_diff2==1? color.red:(ha_diff2==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
plot(13, title="TF3", color=ha_diff3==1? color.red:(ha_diff3==2? color.green: color.white), style=plot.style_circles, linewidth=5, join=true)
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72812497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档