Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

pine script - How to get today's (not current) price of the unrelated security in the pinescript as a variable?

I'm trying to plot BTC over the M1 money supply, but without a coefficient, it is hard to compare the result to the current BTC price. So I'm looking to multiply the result by a coefficient based on today's value of M1.

It works great if I set a hardcoded variable, in this example 6741, but once I uncomment the 2 lines below it uses "current" price at the time of calculation and not "today's" price which is the one I need. Please advise

//@version=4
study("BTC/M1", overlay=true)
var float coefficient = 6741

// ignore the multiplication & division by COINBASE:BTCUSD, it's a TradingView workaround
// temp = security("FRED:M1 * COINBASE:BTCUSD / COINBASE:BTCUSD", "D", close, true)
// coefficient := temp[0]

cc = security("COINBASE:BTCUSD/FRED:M1", timeframe.period, close, true)
plot(cc * coefficient)
question from:https://stackoverflow.com/questions/65835294/how-to-get-todays-not-current-price-of-the-unrelated-security-in-the-pinescri

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...