How will get foreign symbols value as buyprice?

//symol a

buy = condition1;
sell = condition2;

//symol b

serforeign(symbol = b)

buyprice = open;
sellprice = open;


Is this code work for backtesting?

The code is incorrect. It has been explained dozens of times that SetForeign is not meant to "switch" traded symbols. SetForeign should be used to calculate multiple-security indicators and global market timing.
Buy/SellPrices should be within current symbol High-Low range, not something else.

If you want to generate signals based on one symbol (such as index) and trade other symbol you should structure your code THE OTHER WAY ROUND.
I.e. use SetForeign for signal generation only, as explained in the Knowledge Base:


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