How to change foreign symbol name() on month wise



currentMonth = NumToStr(Month(),1.0,False);

// Decide the symbol based on the month
if(currentMonth == "1")
{	
	symbol = "Tatamotors";
}
else if(currentMonth == "2")
{
	symbol = "Reliance";
}// Add more conditions as necessary
else
{
	symbol = "DefaultSymbol"; // Fallback symbol
}

How to change foreign symbol name() on month wise like for January foreign symbol 'Tatamotors' and for February 'Reliance' and so on...
If I am Exploring or Backtesting above mentioned code, it is giving only last symbol ('DefaultSymbol') always, please suggest if any of you have a solution.

Make a list in a string and then use StrExtract()

Use the month number minus 1 to pull the symbol.

@PeterD Thanx for reply, as you suggest

MySymobl_list= StrExtract("Tatamotors, Reliance, Itc, LT, Titan", Month());

here we get error: the second parameter of StrExtract expect a number but found an array.
Could you please explain by code or any example.

Month() returns an array but StrExtract() needs you to tell it which item to return from the list. You can't give it an array.

So you'll have to code something to select the month which returns only one number.

It depends on the context. If you're using it in a chart, maybe SelectedValue() would work. But in an exploration maybe ValueWhen() would work. Maybe a loop would work. Maybe LastValue(). Maybe you would reference one array element (AFL Reference Manual).