Pine-script是一种专门用于编写交易策略和指标的脚本语言,常用于TradingView平台上的技术分析和自动化交易。在Pine-script中,可以使用条件语句来执行多个可选的代码行。 条件语句可以根据特定的条件来决定是否执行某段代码。在Pine-script中,常用的条件语句有if语句和ternary条件运算符。
if time >= timestamp(2022, 1, 1, 0, 0) // 在2022年1月1日之后执行的代码 else // 在2022年1月1日之前执行的代码 上述代码中,如果当前时间晚于或等于2022年1月1日,则执行if语句块中的代码;否则,执行else语句块中的代码。 对于TradingView Pine脚本中的if语句问题,腾讯云没有直接相关的产品或链接提供。
//@variable 每隔一根k线,condition就返回truecondition=bar_index%2==0intcustomIndex=na// 当 condition 为 true 时调用 calcBarIndex(). 这会导致编译器发出警告.ifconditioncustomIndex:=calcBarIndex()plot(bar_index,"Bar index",color=color.green)plot(customIndex,"Custom index",color=color.red,style=...
plot(b, color = color.black, overlay=true) plotshape(c, color = color.red, overlay=true) 或者: longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28)) if (longCondition) strategy.entry("My Long Entry Id", strategy.long) shortCondition = ta.crossunder(ta.sma(close, 1...
pinescript语法中没有end if。 不能在局部作用域中使用plot函数,只能在全局范围内使用。 在本地范围内使用security()函数声明变量将产生编译错误Can't call 'security' inside: 'if', 'for' 解决方案是将所有的calc、security调用和plot函数移到全局范围。 如果您想用PP_display输入隐藏绘图,可以直接在plot函数的...
//@version=5indicator("My Script",overlay=true)src=close a=ta.sma(src,5)b=ta.sma(src,50)c=ta.cross(a,b)plot(a,color=color.blue)plot(b,color=color.black)plotshape(c,color=color.red) 或者是这样写的: //@version=5strategy("My Strategy",overlay=true)longCondition=ta.crossover(ta....
pine-script 关于pine脚本,我有以下几行:differencevalue = math.abs(val-val_1) plot(differencevalue, title="dvalue") 它成功地在指示器窗口上绘图。我还有一个警报功能:alert("{{dvalue}} LONG -> "+ sym, alert.freq_once_per_bar) 但我无法让此警报函数打印“differencevalue”的值。
when = rsi > 50– this is an additional parameter that tells pine script to only execute the trade if the RSI is higher than 50. The syntax for our short entries will follow a very similar format. if (shortCondition) strategy.entry("short", strategy.short, 100, when = rsi < 50) ...
In Pine Script we could detect this candle condition with the following line of code: higherClose = close>= open[1] This variable will turn true only if the current candle’s closing price isgreater than or equal tothe previous candle’s opening price. ...
零基础学Pine Script:基于TradingView平台的量化分析上QQ阅读看本书 新人免费读10天 领看书特权 12.2 函数plot 后续精彩内容,上QQ阅读APP免费读 上QQ阅读看本书,新人免费读10天 登录订阅本章 > 12.3 plot系列的其他函数 后续精彩内容,上QQ阅读APP免费读 上QQ阅读看本书,新人免费读10天 登录订阅本章 >...