pine script v5 - pinescript version 56 i want to plot an option strike ticker's candles to the chart of index - Stack Ov

I want to plot an option chart candle to an opening index chart.like my current chart ticker is nift50

I want to plot an option chart candle to an opening index chart. like my current chart ticker is nift50 index now through indicator i want to draw or plot candles of a option strike like NIFTY250306C22000 but may be i can not get proper or correct approach to do that my code can not draw/plotcandle to the chart. but if i change the base chart from index to any other option strike it works.

here is my code

//@version=5
indicator("Custom Option Candles", overlay=true)
// Input for the custom ticker symbol
customTicker = input.symbol("NSE:NIFTY250306C22000", "Ticker Symbol")
// Define the option ticker
optionTicker = str.tostring(customTicker) //"NSE:NIFTY250306C22000"
// Fetch OHLC data from the option ticker
[optOpen, optHigh, optLow, optClose] = request.security(optionTicker, timeframe.period, [open, high, low, close])
// Check if the fetched data is valid (global scope workaround)
validOptOpen = na(optOpen) ? na : optOpen
validOptHigh = na(optHigh) ? na : optHigh
validOptLow  = na(optLow)  ? na : optLow
validOptClose = na(optClose) ? na : optClose
// Plot candles globally
plotcandle( validOptOpen, validOptHigh, validOptLow, validOptClose, color=(validOptClose >= validOptOpen ? color.green : color.red), wickcolor=color.gray, force_overlay=true)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745058269a4608805.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信