Is there anyway I can create a new customized symbol derived from the difference of two other symbols, without having to manually input Params everytime i need to watch a spread?
@shaun_pai not sure what you are looking for but this might be of use,
http://www.amibroker.com/kb/2016/01/26/how-to-show-price-ratio-between-two-symbols/
I keep a track of the price difference between two symbols. If i use the spread AFL or use foreign keyword and then plot the difference, I need to keep changing the parameters for every symbol. I would like to create a new symbol that is the difference between the two prices. So I wont need to keep updating the parameters.
Agreed! This would be great as that way we could add it to the Realtime Quote window. Largely, this is used in pairs trading where you keep track of the difference between two instruments. For example, you would use SPY - QQQ and get the price difference between the two. Or better yet something like 20 * SPY - 50 * QQQ. Using this as a single symbol would be killer! AB already lets you chart the spread (using a formula) but using this as a symbol itself would be great (as it is available at IB, TOS, etc...)
Hi, I'm reading the manual regarding spreads, but I don't get it right. I want to make a spread between 2 symbols which I want to select in parameters like ticker 1 and ticker2 so I can choose when I want the spread. I do something wrong. I attach the symbol. I have read articles and do not see how. Puff, I'm a denier to program
ParamIndex1= Param("ParamIndex1", 1, 1, 500, 1);
ParamIndex2= Param("ParamIndex1", 2, 1, 500, 1);
spread = ParamIndex1*Foreign("SP500_IDX", "C") - ParamIndex1*Foreign("NG_FMP", "C" );
Plot( spread, "Spread", colorBlack );
_SECTION_BEGIN("spread");
spread = Foreign( "SPX_IDX", "C")/Foreign( "NG_FMP", "C");
Plot( spread, "spread", colorRed);
_SECTION_END();
You may do that via ParamStr() function, for example.
ParamIndex1 = ParamStr("ParamIndex1", "NG_FMP");
ParamIndex2 = ParamStr("ParamIndex2", "SP500_IDX");
spread = Foreign(ParamIndex2, "C") - Foreign(ParamIndex1, "C" );
Plot( spread, "Spread", colorBlack );
_SECTION_BEGIN("spread");
ParamIndex1 = ParamStr("ParamIndex1", "NG_FMP");
ParamIndex2 = ParamStr("ParamIndex2", "SP500_IDX");
spread = Foreign(ParamIndex2, "C")/Foreign( ParamIndex1, "C");
Plot( spread, "spread", colorRed);
_SECTION_END();
Excuse me, a question about the spread. If I wanted to paint the spread I'm analyzing on the chart, how can it appear? or write it a parameter on the same chart and there choose the spread and so I am not confused and see what it is?
regards
Luis