How to convert AFL code (spread) to symbol?

So I have created an AFL which adds the open, high, low and close of 2 instruments. I have named it "SPREAD"

Now I want to compare (relative performance) of SPREAD and index of the market.
I am not able to do this because SPREAD instrument is not in my symbols list. It is just an AFL.

So How do I convert my AFl instrument (spread) to a new symbol so that I can find the correlation between it and the index ?
Please help

@knowperson, like most things in life, there are several ways you can do it...

One idea is to use the AddtoComposite function and create your Spread as a symbol.

Another idea is to just use the Foreign function for the index and do the calculations in the current AFL that you have.

The method you choose depends on what you want/need to do..

Good Luck with your homework...

1 Like

Thanks a lot snoopy for the reply.

Here is the AFL that I created.

symbol1 = ParamStr("instrument1","NIFTYWK11200CE");
symbol2 = ParamStr("instrument2","NIFTYWK11300CE");
symbol3 = ParamStr("instrument3","NIFTYWK11400CE");

open1 = Foreign(symbol1,"Open");
open2 = Foreign(symbol2,"Open");
Open3 = Foreign(symbol3,"Open");

high1 = Foreign(symbol1,"High");
high2 = Foreign(symbol2,"High");
High3 = Foreign(symbol3,"High");

low1 = Foreign(symbol1,"low");
low2 = Foreign(symbol2,"low");
Low3 = Foreign(symbol3,"low");

close1 = Foreign(symbol1,"close");
close2 = Foreign(symbol2,"close");
Close3 = Foreign(symbol3,"close");

open13 = open1+Open3;
high13 = high1+High3;
low113 = low1+Low3;
close13 = close1+Close3;
Close22 = Close2 * 2;
Closefinal = Close13-Close22;

I am not sure how to add the second intrument (Nifty - fut) in this code so that I can compare it with nifty fut.
Can u please help me out with this. I am going with the second method.


Your code shows 3 foreign symbols already, so just add a 4th foreign symbol - the index you want.

Then do whatever calculations you want.


Was just waiting for you to show up after your recent IDs' started threads

Yes, that's right... it is you again @besttrader, @thetrader, @Malibutown, ..., ...

You may ask how do I know... Well, "funnily" you make it (very) easy...

For example here you started thread as @besttrader

Then @ptpdeepu was asking you to provide code example.
And all of the sudden (as before) just seven minutes later it wasn't @besttrader responding but it was mixed up login @knowperson responding to @ptpdeepu.

But even without that mistake there are of other similarities in other posts. That one above has just been the most obvious one.

So we are at four IDs now (I know there're more ones).

Once again the question to you... what do you intend to achieve by fooling other readers via your multi IDs? What's your plan? Do you expect more responses if you get none with just one ID?

Please stop using multi IDs. It will be exposed anyway because of mixing up logins, leaving "fingerprints", patterns in sentences & codes.

The way you use your multi IDs is not smart one as they are easily recognizable.
So best keeping just single ID (just one of the four upper ones+other ones) without fooling around. The outcome will be same one.


Next one will be Dementia ID.


Good one.

Maybe he can't decide which name to use. Maybe he looks for help by community on getting name.

How about "Vampy", the cute little help vampire.

Or maybe in style of Jose Mourinho... "The_most_special_one" or just "VIP".

Or what about just... "Just_me_again".

1 Like

Multiple IDs, but I wonder if among all those users :wink: at least one has a genuine AmiBroker licence?

I quote Tomasz from this post:

Keep in mind that you should have legal purchased license to use AmiBroker. Make sure you use registered email address for this forum.

In near future we will probably start differentiating user accounts on the forum to show their status.

Let's hope that this idea is implemented one day so that everyone could clearly see if someone is a registered, legal AmiBroker user or not. I don't see a reason why AB developer and AmiBroker customers should regularly support people who do a lot not to support AmiBroker at all.