Duplicate: BackTest on Foreign Key

Hello Gurus

I need to do a back test on a foreign key ( options ) which i will choose from the current ticker price .
When i do a backtest i am only getting buy-sell results for current ticker but not the foreign ticker which i will actually buy .

Please help
I am posting my code below .
I am new to AFL please bear me if there are blunders in my code

_SECTION_BEGIN("ShortStranglebacktesting");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

SetForeign("INFY",True,True); 

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Period1 = param("Period1",55,10,100,5);
Period2 = param("Period2",20,10,100,5);
Period3 = param("Period3",10,10,100,5);
Period4 = param("Period4",115,10,100,5);

//color =ParamColor( "Color", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
Plot(tEMA(Close,period1), "EMA_Period1",colorAqua,styleThick);
Plot(tEMA(Close,period2), "EMA_Period2",colorGreen,styleThick);
Plot(tEMA(open,period3), "EMA_Period3",colorOrange,styleThick);
Plot(tEMA(Close,period4), "EMA_Period4",colorViolet,styleThick);
Plot( C, "",colorAqua, styleCandle );
Buy = Cross(tEMA(close,period3),tEMA(close,period4));
Sell = Cross(TEMA(Close,period2),tEMA(Close,period4));
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,buy);
AlertIF( Buy," ","Simple text alert", 1+2+4+8 );
Short = Sell;
Cover= Buy;
BuyPrice = Open;
val1 = LastValue(BuyPrice);

SellPrice = Open;
val1 = ValueWhen(Sell,Close);
price = LastValue(val1);

CoverPrice = Open;
ShortPrice = Open;
/* Using PLOT SHAPES :Plot Buy and Sell Signal Arrows */
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorGreen, 0, L, Offset = -40 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -50 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -45 );
PlotShapes( IIf( Sell, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 40 );
PlotShapes( IIf( Sell, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 50 );
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offset = -45 );

e = Equity(1); // backtest on infy
RestorePriceArrays(True); 

Thank you

It has been written many many times that you should do the OTHER WAY ROUND,
i.e. do calculations using Foreign (if you need) but trade ALWAYS ON CURRENT symbol.

Many duplicates exist, use search before posting:

https://forum.amibroker.com/search?q=SetForeign%20backtest

Duplicate topic to many already existing topics.