How to get Call and Put Open Interest on same chart

_SECTION_BEGIN("FRG1");

Ticker = ParamStr("Foreign Ticker", "BANKNIFTY20OCT24900CE"); //For foreign Call option

SetForeign(Ticker);

periods = Param( "Periods", 15, 1, 200, 1 );
RF=Foreign("","OpenInt");

Plot( RF, "",IIf(RF>0,colorYellow,colorBlue),styleLine);

RestorePriceArrays();

_SECTION_END();

_SECTION_BEGIN("Open Interest"); // Original Put option
Plot( OpenInt, _DEFAULT_NAME(), ParamColor("Color", colorCycle ), ParamStyle( "Style" ) );
_SECTION_END();

You should not combine SetForeign with Foreign. Either use one or other. Since you look for single data field only you just need single Foreign call. Also function arguments of Foreign() are not correct in upper code, First argument is supposed to be ticker name and second argument is data field. Data field for open interest is "I".

_SECTION_BEGIN("FRG1");
Ticker = ParamStr("Foreign Ticker", "BANKNIFTY20OCT24900CE"); //For foreign Call option
//periods = Param( "Periods", 15, 1, 200, 1 );// unused
RF=Foreign(Ticker,"I");// Open interest field of foreign ticker.
Plot(RF, "",IIf(RF>0,colorYellow,colorBlue),styleLine);
_SECTION_END();

_SECTION_BEGIN("Open Interest"); // Original Put option
Plot( OpenInt, _DEFAULT_NAME(), ParamColor("Color", colorCycle ), ParamStyle( "Style" ) );
_SECTION_END();

FYI please read this pinned thread first before your next post (especially on how to apply code tags, see animation there).

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.