AmiBroker formula Language

kkseal

Well-Known Member
Yes Kalyan u r correct but I am completely new for this programming it is not that I will grasp in one day everything I am trying at my best and reading now all the alf functions so it will take some time just u write the code once then i will try to practice next.
thnx for ur encouraging word.
Ok this once.

x = MA(AdvIssues(),10)/MA(DecIssues(),10);

BUY = x > 0.75 AND CROSS(RSI(8),30);
SELL = CROSS(0.5,x) OR CROSS(65,RSI(8));

FILTER = BUY OR SELL;

ADDCOLUMN(x, "Adv/Decl");
ADDCOLUMN(RSI(8), "RSI");

Since this is more relevant for trading Index you can expand the FILTER to the following

FILTER = (BUY OR SELL) AND StrFind(StrToUpper(NAME()), "NIFTY");

(However not sure about the last part - never used it before)

Regards,
Kalyan.
 
Last edited:
thnx kalyan for the coding but the code doesn’t show any result neither any buy signal nor any sell but it's not a matter at list I know the procedure how to write the alf coding
thnx again
 
thnx kalyan for the coding but the code doesnt show any result neither any buy signal nor any sell but it's not a matter at list I know the procedure how to write the alf coding
thnx again
Hi,

As Kalyan tells, just concentrate on knowing the main coding part in AFL. Colours, arrows, filter, etc are simple and can be added later.

You can look at this AFL skeleton code, which will help in the latter part mentioned above: http://www.traderji.com/82731-post93.html

Praveen.
 

kkseal

Well-Known Member
Mishphar,

There might be some issue with setting up the composites etc. I'll check it out and get back to you soon.

Don't worry, it'll work.

Regards,
Kalyan.
 

kkseal

Well-Known Member
Ok here we go. (The first 3 Steps invlve the necessary groundwork while the 4th step is the coding & execution)


STEP I : Seting IsIndex property for base Index

In symbols pane Select NIFTY (or whatever symbol name you have for the NIFTY index)
Goto Symbol->Information menu item and scroll down to Composites in the Information dialog box that appears. Set IsIndex property to 'yes'.

STEP II : Seting base Index for Composites

Open Categories window using Symbol -> Categories menu item.
Select NSE (or whatever mkt name you have) in Markets tab
In 'Base indexes for - Composites' combo enter NIFTY (or whatever symbol name you have for the NIFTY index)

STEP III : Calculating Adv/Decl composites

Choose "Symbol ->Calculate composites" menu item to open the Composites recalculation window
Check Number of advancing/declining issues. In 'Apply to' Select 'All quotes'and 'This market'->Select NSE (or whatever mkt name you have).
Click Calculate (this will take some time, you can however choose to use just the past 3/6/12 mths data. Enter the date range/no. of bars accordingly)

STEP IV: Coding & Executing

The Exploration code :

x = MA(AdvIssues(),10)/MA(DecIssues(),10);

Buy = x > 0.75 AND Cross(RSI(8),30);
Sell = Cross(0.5,x) OR Cross(65,RSI(8));

Filter = (Buy OR Sell); //AND IsIndex();*

AddColumn(x, "Adv/Decl");
AddColumn(RSI(8), "RSI");
AddColumn( IIf( Buy, Asc("B"), Asc("S")), "Signal", formatChar );
Open Formula Editor using Analysis->Formula Editor menu, type the formula and choose Tools->Send to Automatic Analysis menu in Formula editor
To base your exploration on the most recent quote you should choose "n last quotations" and "n=1"
-------------
* If you include the IsIndex() flag and get no output for n=1, increase the value to 10,20,30. However this for testing only.

MISCELLANY :

You can include other tradable indices (like CNX IT, BANK NIFTY, CNX NIFTY Jr, CNX 100) in your Exploration by setting their IsIndex property to True as in Step I.
If you're using the ASCII Importer you can Calculate composites automatically while importing data by checking the 'calculate Composites' option in the Import dialog.
Check the EXREM function to remove excessive (consecutive buys or sells) signals.

Regards,
Kalyan.
 
Yes Kalyan u r a genius I can’t believe that u hv so depth knowledge about Amibroker ok its fine but from to-day I will call u as my GURU may GOD blessed u
Thnx
mishphar
 
Hi,

I'm new to AMIBROKER. Recently I've found the metastock code for ELDER AUTO ENVELOPE. Can anyone plz convert it to AFL. Thanks
Regards


MS FORMULA

EMA:=Input("Base EMA",1,100,22);
Factor:=Input("Factor",1,50,27);
avg:=Mov(C,EMA,E);
csize:= Stdev(2*Max(Abs(H-avg) ,Abs(L-avg)) / avg,100)*Factor/10;
{Use 100 days for stable channel size - default is 2.7 std}
Csize:= ValueWhen(1,
DayOfWeek()<Ref(DayOfWeek() ,-1) OR (
DayOfWeek()=Ref(DayOfWeek(),-1) AND DayOfMonth() <> Ref(DayOfMonth(),-1))
,Ref(csize,-1));
{ This pegs the Stdev to last bar of week and only changes once per week}
csize:=LastValue(csize);
{fix to constant using last value}
channel:=csize*avg;
avg+channel/2;
avg-channel/2;
avg;
 

kkseal

Well-Known Member
Yes Kalyan u r a genius I can’t believe that u hv so depth knowledge about Amibroker ok its fine but from to-day I will call u as my GURU may GOD blessed u
Thnx
mishphar
Thanks. But please don't fall prey to the far-too-common malady of guru-ism.

There's only one guru - KNOWLEDGE & only one genius - IT'S APPLICATION. (The rest is nothing more than disabling mental crutches)

For more ideas on marketwide composite indicators see the Market Internals thread by Sunil Saranjame (he has done it all in Excel without the help of Ami - which makes him a greater guru :))

To see how you can make composite indicators even out of stuff like the RSI, check the ADDTOCOMPOSITE function in Ami.

Regards,
Kalyan.
 
HI
I am having esignal data feed with Amibroker 5 trail version.
While stock charts are getting updated realtime, Futures/derivatives charts are not getting updated realtime.

Two Charts of nifty spot and nity futures enclosed

RMO Oscillator and 200 EMA are developed courtesy :=sSenior members of this Forum.

Any members have faced similar problems and what is the solution.

Thanks in advance

SRJC
 

Similar threads