How to Create Variable for Max OI Strike in Bank Nifty
Keyword help1,155 views
MEGHARAJ
I want to create Instrument for Max OI Strike, so that at market Opening 0915, it records CE and PE strikes and CE and PE Instruments so that they could be fetched via Get runtime and EMA crossover could be used on these instruments. I have tried as below attached images. But they are not working.
Use Max OI Strike for the strike and Max OI Instrument for the option itself, and save them in runtime variables.
The keywords
Max OI Strike('BANKNIFTY', <expiry>, 'CE', 'strike') returns the CE strike with the highest open interest. Use 'PE' for puts.
Max OI Instrument('BANKNIFTY', <expiry>, 'CE', 'instrument_name') returns that option’s instrument, which you can then use for prices and candles.
The underlying is the short index name (e.g. 'BANKNIFTY', 'NIFTY'), and the expiry is written as text such as 'current month' or 'current week'. Pick the expiry your index actually lists.
Saving them at 09:15
Runtime variables are written when a block’s leg is taken. So store the values in the Runtime section of a block that trades at that time (for example your first entry), not in a condition on its own. Read them later with Get Runtime.
Tips
Max OI changes during the day. A value stored at 09:15 stays fixed until you overwrite it.
If the EMA crossover runs on the stored option, check in the Notification Log that the instrument name was stored as you expect.