pine-script - Pinescript 策略未绘制
问题描述
我正在尝试根据以下条件为图表创建绘图:
- 这是连续第二个在 9 日均线上方开盘的绿色柱
- RSI 超卖
但是,它似乎没有在绘图,我感觉 greenbc 变量由于某种原因返回 false - 有什么想法吗?
strategy(title="Swing Strat", pyramiding=1, overlay=true, default_qty_value=2, default_qty_type=strategy.fixed, initial_capital=100, currency=currency.GBP)
//Plotting SMA 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
//identifying green confirmation bar
MAcrossover = crossover(close, MA9)
entrypoint = barssince(MAcrossover)
greenbc = entrypoint==1 and MA9<open and open<close and open[1]<close[1]
//combining the green bar confirmation and oversold variable
tradingsignal = ((isOversold or isOversold[1]) and greenbc)
//plotting the entry point to the chart
plotshape(tradingsignal and greenbc, title="Entry Trigger", location=location.abovebar, color=color.red, transp=0, style=label.style_xcross, text="Entry Point")
解决方案
绘制您的个人条件,以了解它们是否一致触发。
plotchar(entrypoint, 'Entry Point','')
plotchar(greenbc,'Greenbc','')
等等。
plotshape 函数需要一种形状样式。style=shape.cross
plotshape 中的 greenbc 是多余的,因为它已经用于创建交易信号。
推荐阅读
- python - 对于每个原始类型,Python 认为什么是 True 或 False?
- typescript - 打字稿,为类中的可选参数设置默认值
- java - How to run spring boot application in windows which is developed in eclipse in Ubuntu os?
- java - 硒 WebDriver + java 。按类名定位
- c# - .NET Core 3.1 CreateHostBuilder 无法解析 JSON 文件
- networking - 如何调试 NetworkManager 共享连接
- node.js - 在 Eclipse 中运行 npm 脚本
- performance - 我应该将 JMeter 与 Selenium 和 junit 一起用于 Web 应用程序的负载和性能测试吗?
- html - 如何使用 html 显示电子邮件的嵌入图像?
- django - Django:查询相互关联的模态......如何最好地实现预取或选择相关?