Pine Script 在图表上绘制 MACD 线和信号线

huangapple go评论76阅读模式
英文:

Pine Script plot MACD line and signal line on chart

问题

在我的TradingView策略中,我想要在我的图表上方绘制MACD的macdLine和signalLine。

// 本源代码受 Mozilla Public License 2.0 条款约束,详情请参阅 https://mozilla.org/MPL/2.0/

//@version=5
strategy('MACD',
overlay=true,
process_orders_on_close=true,
default_qty_type=strategy.percent_of_equity,
initial_capital=1000,
default_qty_value=100)

[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
plot(macdLine, color=color.blue)
plot(signalLine, color=color.orange)


当我的策略的overlay属性设置为true时,这些线条不会绘制在我的图表上方。如果将其设置为false,它会添加MACD线条,一切都正常。

如何在overlay=true的情况下将它们绘制在我的图表上方呢?
英文:

In my tradingview strategy I would like to plot the MACD macdLine and signalLine ontop of my chart.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=5
strategy('MACD',
   overlay=true,
   process_orders_on_close=true,
   default_qty_type=strategy.percent_of_equity,
   initial_capital=1000,
   default_qty_value=100)

[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
plot(macdLine, color=color.blue)
plot(signalLine, color=color.orange)

When the overlay attribute of my strategy is set to true, the lines are not plotted ontop of my chart. If it is set to false, it adds the MACD lines and everything is fine.

How can I draw them in overlay=true ontop of my chart?

答案1

得分: 1

使用 overlay=true 时,会绘制 MACD 线,但您看不到它,因为您的图表肯定位于另一个刻度。

英文:

With overlay=true your MACD lines are plotted, but you don't see it because your chart is certainly at another scale.<br>

huangapple
  • 本文由 发表于 2023年2月19日 17:09:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499063.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定