SetForeign Use case

My use case is I am trying to use SetForeign to trade on a foreign (read futures series) ticker using current base ticker (underlying of futures).

The rationale is that the number of bars of futures is less due to low liquidity as compared to the current underlying hence I want to use underlying as the base ticker on which signals are generated and then the trade prices are picked from the futures of same.

The issue that I am facing is I see a crash every time I run the backtest. Note the number of bars of futures is less I want to run on underlying ticker but use the trade prices from futures (using fixup = 1 and tradePrices = true) but whenever I try to SetForeign or RestorePrices(True) I get a crash report. Can someone please help me figure what I might be doing wrong?

futName = Name()+"FUT"; // that is how names for futures series are stored in my database
if(SetForeign(futName, 1, True))
{
BuyPrice = SellPrice = ShortPrice = CoverPrice = Close;
SetPositionSize(100000, spsValue);
e = Equity();
RestorePriceArrays(True);
}

PS: I have already increased In-memory cache and also number of tickers (I don’t use more than two tickers at once)

You don’t have Buy/Sell/Cover/Short variables defined in your code. They are required for backtesting.

This is a snippet from my entire code. The code before this snippet defines all buy/sell/short/cover conditions and then I do this so that I can trade on futures series. Do you see any problem with the snippet, please do let me know what more information you would need to spot the issue?

General principle of all submissions to the forum:
You should provide 100 % working code that demonstrates the issue so it can be copy-pasted and tried on somebody’s else computer. Otherwise you leave others to do guessing work what you left out.