Foreign Indicator issues

Hi, I needed some help in one of my AFL codes.

This is what I'm trying to achieve:

  • Use Foreign and generate an indicator array
  • Use that indicator to make a decision of buy / sell on the selected ticker (In this case weekly option contracts)

Independently, the indicator on foreign array works just fine but when I run a backtest I see that many a times the foreign indicator array is EMPTY - thus not causing my code to run as expected. After going through the forum, I believe, the issue could be in regards to some holes in my traded ticker value.

Pad & Align might not be viable here due to the time it takes. Also the Option contracts are active only for certain periods (till they expire) while the reference symbol is an index.

I'm wondering if AddtoComposite / StaticVarSet might help in this case - to try and build a temp ticker for the indicator, call it using foreign and check it. Did attempt the same but I am unable to get it running. Any help would be really appreciated.

SetForeign("BANKNIFTY",True,True);
AddColumn(Close, "5min Close");
TimeFrameSet(inHourly);
AddColumn(supert = SuperTrend(10,3),"Supertrend compressed");
TimeFrameRestore();
SuperT = TimeFrameExpand(supert, inHourly);
RestorePriceArrays();

If I just do an exploration on the SuperT variable it works fine, the issue comes up when I run a backtest with the underlying ticker.

I am okay to pad the indicator values with previous values or any other better option that you might suggest.

Hope the above was a clear explanation of what I'm trying to achieve. Thanks.

@portfoliobuilder - Saw some of your posts regarding StaticVarSet - would that be something that works here ?