How to create a customized ticker for usage with pair trading strategy?

Dear members,

I am new to Amibroker. I have tried to create a customized ticker (e.g. KO/PEP) for pair trading strategy review in Trading view and it is possible. I just wonder whether I can create such a customized ticker in Amibroker and then treat it like a usual ticker. It does mean I can plot OHLC of this new ticker in chart and do the exploration with this new ticker. Could you guys please help me with this !!! Thank you very much.

As chart symbol select KO in UI ticker box.
16


Then go to Charts - Basic Charts - Spread and double click it.
14


In parameters insert PEP and set mode Ratio.
In Style setting choose style of your choice.
15

3 Likes

Hi @fxshrat,

Thank you very much for your help. Following your comments, I can calculate some simple indicators (such as MA), as well as plot the different kinds of graph for the ratio (e.g BA/SPX) but I find a bit difficult to display or calculate some indicators like ADX for this ratio. Is it possible to do it ?!!!

The following is MA for the ratio

_SECTION_BEGIN("MA");

_N( SymbolY= ParamStr("SymbolY", "^GSPC") );
Mode = ParamToggle("Mode", "Pair (Symbol/SPX)");
SetForeign(SymbolY);
OY = O;
HY = H;
LY = L;
CY = C;
VY = V;
RestorePriceArrays();
OP = O*1000/OY;
HP = H*1000/HY;
LP = L*1000/LY;
CP = C*1000/CY;

Plot( MA( CP, 200 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

Dear @fxshrat,

I have found the manual formulas of adx and tailored it in the same way like MA, and it works well. :smiley:

What manual formulas?

You can just use inbuilt ADX function

H = HP;
L = LP;
C = CP;
sp_adx = ADX(14);
RestorePriceArrays();

So,

_N( SymbolY= ParamStr("SymbolY", "^GSPC") );

SetForeign(SymbolY);
OY = O;
HY = H;
LY = L;
CY = C;
VY = V;
RestorePriceArrays();

OP = O*1000/OY;
HP = H*1000/HY;
LP = L*1000/LY;
CP = C*1000/CY;

H = HP;
L = LP;
C = CP;
sp_adx = ADX(14);
RestorePriceArrays();

Plot( sp_adx, "ADX", colorRed, styleLine );
2 Likes

hi @fxshrat,

I mean the detail calculation of adx found from the below conversation. Both work however, your approach with inbuilt is much better and more efficient. Thank you very much !!!

This conversation about adx calculation

Is there a way to save the pair tickers such as "KO/PEP" in a watchlist and scroll through spread ratio charts one by one?

1 Like