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条)