Pinescrip条件语句绘制 [英] Pinescript conditional statement plotting

查看:12
本文介绍了Pinescrip条件语句绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据以下条件创建图表的曲线图:

  1. 这是连续第二个在9日均线上方开盘的绿色条形
  2. 在RSI上超卖

我的问题是写条件的顺序是什么,以及我需要多少个括号?

strategy(title="Swing Strat", pyramiding=1, overlay=true, default_qty_value=2, default_qty_type=strategy.fixed, initial_capital=100, currency=currency.GBP)


//plotting MA lines
MAPeriod9 = input(9, title="9 MA Period")
MA9 = sma(close, MAPeriod9)
MAPeriod180 = input(180, title="180 MA Period")
MA180 = sma(close, MAPeriod180)

plot(MA9, color=color.blue, linewidth=1)
plot(MA180, color=color.red, linewidth=1)

// creating the RSI
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=14)

rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=70)
rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=30)

//get RSI value
rsiValue = rsi(rsiSource, rsiLength)
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOversold

//checking to see if the bars close over 9 day MA line
MAcrossover = crossover(close, MA9)
entrypoint = barssince(MAcrossover)

//marking the second green bar to open above the SMA line
tradingsignal = ((entrypoint==1 and MA9<open and open<close and open[1]<close[1]) and isOversold)
plotshape(tradingsignal, title="Entry Trigger", location=location.abovebar, color=color.red, transp=0, style=label.style_xcross, text="Entry Point")

推荐答案

您在条件中没有错误。在您的情况下,您可以删除所有括号。 将最后一行中的style参数更正为以下style=shape.xcross。 如果您在图表上看不到任何带有Entry Point的标签,请增加超卖参数的值。

这篇关于Pinescrip条件语句绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆