Hi,

You need to understand that the indicators of a chart are applied to the active 
symbol. Whatever symbol you have showing in the toolbar area will be the symbol 
upon which the chart is applied.

Like all the other indicators, your custom indicator is only being applied to 
the one active symbol. However, since you are programmatically defining an 
array and then charting that array, ignoring the current symbol, it draws fine. 
This is due entirely to the implementation of your indicator (i.e. it hard 
codes the symbols upon which it gathers data).

If you want all indicators on the chart to apply to your spread, then you have 
two options:

1. Hand modify the code to use SetForeign/RestorePriceArrays around all 
indicator code. The downside is that it requires intervention every time you 
add a new indicator.

2. Create a composite symbol for the spread (using a simple scan or 
exploration), then load that composite symbol as the active symbol (in the 
toolbar) such that any indicators added to your chart will be applied to your 
composite (i.e. the active symbol). This is, perhaps, the better approach.

See the following for additional information:
http://www.amibroker.com/guide/a_addtocomposite.html
http://www.amibroker.net/3rdparty/IntroToAtc.pdf

Mike

--- In [email protected], "bertieb_aus" <bertieb_...@...> wrote:
>
> I am trying to chart the RSI on a spread I have created between two existing  
> symbols.
> 
> (I wanted to post this in a new message to see if someone could help.)
> 
> I cannot seem to place a study on a new spread I have created : all the 
> studies are on one of the instruments in the spread only.
> 
> For example I have writing an AFL formula that sits under the 'Custom' 
> section of my chart box. The formula is :
> 
> _SECTION_BEGIN("IR_ED Spread");
> spread=Foreign("YIR2_CCS","C") - Foreign("ED___CCS","C");
> SetChartOptions(0,chartShowArrows|chartShowDates);
> _N(Title = StrFormat("{{IR_ED Spread} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, 
> Lo
> %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) 
> ));
> Plot(spread,"spread",colorRed);
> _SECTION_END();
> 
> (the four main lines begin spread, setchartoptions, _N, plot(ie no word
> wrapping)
> 
> If I call up a blank chart, and drag this custom spread over to it, it charts 
> perfectly. However the title bar of the window is "YIR2_CCS" - ie one of the 
> symbols only.
> 
> If I then drag a study ('indicator') over to it (RSI / Stochastics etc), the 
> studies are ONLY on YIR2_CCS, and not what I want which is on the spread.
> 
> I have looked through both the user guide and my copy of 'Introduction to 
> Amibroker', but cant find anything relevant.
> 
> Can anyone possibly offer some assistance - it would be very much appreciated.
> 
> bertieb
>


Reply via email to