When using SetForeign displayed chart name is incorrect?

Hi,

I’m trying to display a different ticker to the current ticker and to do so I’m using the following sample code…

_SECTION_BEGIN("Price");
SetForeign( "$SP" );
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() ); 
RestorePriceArrays();
_SECTION_END();

For some reason, although the chart plot is correct, the ‘NAME’ parameter returns the name of the current ticker and not the foreign ticker. Is this the expected behaviour? Is there a way of displaying the name of the foreign ticker?

Moderator comment: I had to fix your post incorrect formatting of code. You need to READ HOW TO USE THIS SITE and format your code properly.

Either you add your set name of setforeign’s 1st argument (since you have to set name of your choice anyway) in title.

_SECTION_BEGIN("ForeignPrice");
SetChartOptions(0,chartShowArrows|chartShowDates);

frg_nm = "$SP";
SetForeign( frg_nm );
_N(Title = StrFormat( frg_nm + " - {{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() );
RestorePriceArrays();
_SECTION_END();

OR… use Name() function in Title variable.

_SECTION_BEGIN("ForeignPrice");
SetChartOptions(0,chartShowArrows|chartShowDates);

SetForeign( "$SP" );
_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() );
RestorePriceArrays();
_SECTION_END();
1 Like

Thank you for the answers.