Pine-script是一种专门用于编写交易策略和指标的脚本语言,常用于TradingView平台上的技术分析和自动化交易。在Pine-script中,可以使用条件语句来执行多个可选的代码行。 条件语句可以根据特定的条件来决定是否执行某段代码。在Pine-script中,常用的条件语句有if语句和ternary条件运算符。
带图的If语句是Pine脚本中的条件语句,用于根据满足条件的情况执行相应的代码块。它的语法结构如下: 代码语言:txt 复制 if condition // code block else if condition // code block else // code block 其中,condition为条件表达式,用于判断是否满足特定条件。如果满足条件,执行相应的code block;如果不满足,则跳过...
//@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”的值。
零基础学Pine Script:基于TradingView平台的量化分析上QQ阅读看本书 新人免费读10天 领看书特权 12.2 函数plot 后续精彩内容,上QQ阅读APP免费读 上QQ阅读看本书,新人免费读10天 登录订阅本章 > 12.3 plot系列的其他函数 后续精彩内容,上QQ阅读APP免费读 上QQ阅读看本书,新人免费读10天 登录订阅本章 >...
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. ...
if close < close[1] line_color := color.red line_color plot(close, color=line_color) bgcolor(line_color, transp=90) How & Why Publish TradingView Pine Scripts To publish a script publicly it needs to be original, useful and it needs a good description to let other traders understand ...