简体   繁体   English

Pinescript:在指标中引用另一种证券

[英]Pinescript: Referencing another security in an indicator

I'm attempting to make an indicator that references a moving average of a different security.我正在尝试制作一个参考不同证券的移动平均线的指标。

For example: Change the color of candles on "ETHUSD" chart if "BTCUSD" price is above the 200 day weekly moving average.例如:如果“BTCUSD”价格高于 200 天每周移动平均线,则更改“ETHUSD”图表上的蜡烛颜色。

I haven't found a way to reference the data of a moving average on a different security or symbol.我还没有找到一种方法来引用不同证券或交易品种的移动平均线数据。 I'm not sure if this is even possible within Pinescript of Tradingview.我不确定这在 Tradingview 的 Pinescript 中是否可行。

Any help would be greatly appreciated.任何帮助将不胜感激。 Thanks for your time!谢谢你的时间!

Sure it's possible.当然有可能。 Use something like:使用类似的东西:

//@version=4
study("", "", true)
priceIsAboveMa = close > sma(close, 200)
btcPriceIsAboveMa = security("BITSTAMP:BTCUSD", "D", priceIsAboveMa)
barcolor(btcPriceIsAboveMa ? color.lime : color.red)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM