Traderji.com - Discussion forum for Stocks Commodities & Forex

AmiBroker formula Language

Discuss AmiBroker formula Language at the AmiBroker within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Originally Posted by bvpraveen Hi, To add to Subratabera's code, the below AFL is the ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Software > AmiBroker

Notices


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #91  
Old 22nd March 2007, 11:22 AM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Quote:
Originally Posted by bvpraveen View Post
Hi,

To add to Subratabera's code, the below AFL is the generalized one. You can give any EMA periods to both short and long periods.

You can use it for Explore also in Automatic Analysis.
......
Praveen.
Hi,

A small mistake in the AFL. Change the MyColor line to
MYcolor = IIf( EMA(C,ShortPeriod) > EMA(C,LongPeriod), colorBrightGreen, IIf(EMA(C,LongPeriod) > EMA(C,ShortPeriod), colorRed, colorBlue));

Praveen.
Reply With Quote
  #92  
Old 22nd March 2007, 11:26 AM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Hi all,

I'm providing here with the skeleton code to write AFLs. This will help any AFL writers and should prove much useful to the beginners.

AFL skeleton code:
In simpler terms, an AFL can be broadly divided into:

1. Trading signal variables and its associates.
2. Common code in every AFL.


Trading signal variables and its associates:
This refers to the variables, which actually makes different trading systems. They are Buy and Sell variables. Whatever may be ones system, only the condition assigned changes.

Their corresponding associates are the ones, which are needed to further set the required settings, like MA period, Colour of bars/lines, sensitivity, etc.

Buy/Sell and at times their associates are the ONLY codes that changes for each and every AFL.


Common code in every AFL:
Every AFL will have some common repeated code like -
* Displaying title, OHLC prices, ticket name
* BUY and SELL arrows
* OHLC bars/lines/candlestics, etc
* Explore codes for filtering in Automatic Analysis.

Since the above are common to every AFL, their corresponding code can be reused in every AFL. This point is the focus of this post. Below you can find the skeleton AFL code, which contains all the necessary code for plotting the default "common requirements".


Steps to use this skeleton code:
When you want to write an AFL, just follow this simple procedure:
1. Copy the skeleton code.
2. Write your BUY and SELL signal conditions, and their associates(if needed).
ie change the red and bolded letters in the skeleton.


Thats it! Your AFL is ready. So you can write AFL's without depending on others.


Code:
_SECTION_BEGIN("YOUR_SYSTEM_NAME_COMES_HERE");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));

Buy = YOUR_BUY_CONDITIONS_COMES_HERE;
Sell = YOUR_SELL_CONDITIONS_COMES_HERE;

MyColor = IIf(Buy, colorBrightGreen, colorRed);
// The above line is very generalized. You can use your own conditions to
// get exact colour combinatins.
// Example :
// MYcolor = IIf( EMA(C,ShortPeriod) > EMA(C,LongPeriod), colorBrightGreen, 
// IIf(EMA(C,LongPeriod) > EMA(C,ShortPeriod) AND C < Peak(C,5,1), colorRed, 
// colorBlue));

PlotOHLC( Open,  High,  Low,  Close, "", Mycolor, styleBar   ); 

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf( Buy, colorGreen, colorRed ) );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorDefault, bkcolor =IIf (Buy,colorGreen, colorRed ));
_SECTION_END();

For a sample AFL with the above skeleton used, please refer this link:
http://www.traderji.com/82702-post90.html


Please let me know, if I'm wrong anywhere.
Praveen.


P.S: This is given to aid the AFL writers, especially beginners, for writing simpel to medium complex AFLs. More code has to be written if the system being developed is complex.

Last edited by bvpraveen; 22nd March 2007 at 05:10 PM.
Reply With Quote
  #93  
Old 24th March 2007, 06:37 PM
Member
 
Join Date: Jul 2006
Posts: 257
Thanks: 1
Thanked 0 Times in 0 Posts
rkgoyal_98 is on a distinguished road
Reputation: 18
Default Re: AmiBroker formula Language

Dear Seniors,

I need help to write an AFL to find out the following
1. List out all the scrips selected for analysis
2. Moving Average
EMA 7 Above EMA 100
1. EMA 7 above EMA 35 UP
2. EMA 7 Below EMA 35 UP-B35
EMA 7 Below EMA 100
3. EMA 7 Below EMA 35 - DOWN
4. EMA 7 Above EMA 35 Down – A35
MACD – Above Zero line and MACD Above Signal – UP, MACD above Zero line but Below Signal Line – UP-Watch, below Zero line and MACD below Signal – Down, MACD below Zero line but above Signal Line – Down-Watch,
4. ADX
• Slop – UP/Down/Flat
• Value of ADX ( showing – Value if –DI is more than +DI & + Value if +DI is more than –DI
5. Value of RSI
Output columns should have Scrip Name (Ticker), Moving average Position, MACD, ADX slope, ADX Value, RSI
I will like to use Default Amibroker values for MACD, RSI, ADX, +DI, -DI
Kindly guide me to wrte above fornulla
Thanks
Rajeev
Reply With Quote
  #94  
Old 24th March 2007, 07:06 PM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Quote:
Originally Posted by rkgoyal_98 View Post
Dear Seniors,

I need help to write an AFL to find out the following
....
....
Kindly guide me to wrte above fornulla
....
Hi,

1. Read some sample AFLs, and try to look for how BUY and SELL conditions are written.
2. Refer Amibroker User Guide to look out for usage of different functions for your requirement, like MA, MACD, etc
3. You can use the AFL skeleton code posted before.

Praveen.
Reply With Quote
  #95  
Old 25th March 2007, 12:21 PM
Member
 
Join Date: Jul 2006
Posts: 257
Thanks: 1
Thanked 0 Times in 0 Posts
rkgoyal_98 is on a distinguished road
Reputation: 18
Default Re: AmiBroker formula Language

Dear Praveen,

I have tried to look at the Formulla and also tried a few AFLs from different sources. As i understand there may be 2 kinds of AFLs.
1. In which we may want to plot the charts with our desired results i.e. we may want to put indications on the chart for Buy/Sell or another Indication. The Best example i saw here was the default formulla that plots the default chart it self
On further examination of this formulla i found following Parts
1. For displaying title and tool tip.
2. For plotting Moving Averages , BBANDS, and Volume
3. For displaying the price interpretation

Now i want a confirmation from you regarding my observations of the above
If this is correct then my Next query is that since in explorations/scans we need not to plot anything but only want some output from the data can we go about without such parts of the secion

i was also trying one simple test scan to find out just cross of one EMA over the other and found that it is fine
Small = 7;
Medium = 35;
Large = 100;
Buy = Cross(EMA(C,Small),EMA(C,Large));
Sell = Cross(EMA(C,Medium),EMA(C,Small)) AND EMA(C,Medium) > EMA (C,Large);
Short = Cross(EMA(C,Large),EMA(C,Small));
Cover = Cross(EMA(C,Small),EMA(C,Medium)) AND EMA(C,Large) > EMA (C,Small);
This was giving me Results in the scan window however the result are not perfact as there may come up a short condition before sell condition exist (may be because Medium MA was higher than large MA and the stock turns back southwards). In this case Shorting indication has to be used to exit the position (Sell). after sometime stock may just make small up/down moves and there may be again a penetration southwards.
all the indications are being given ok
but i want the formulla to test that if there was a buy condtion satisfied and if there is shorting condition before Sell Condition then it should be acutually a sell conotion and not a shorting condition

I also need further help in generating output as i mentioned in my previous post but since no proper guidelines exist even in help file, i have asked u about it

I have some knowledge of Visual Basic and ASP programming

Thanks

Rajeev
Reply With Quote
  #96  
Old 26th March 2007, 08:46 AM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Quote:
I have tried to look at the Formulla and also tried a few AFLs from different sources.
Glad to hear that you are trying to learn AFLs, and trying your best to write your own AFLs.

Quote:
...
since in explorations/scans we need not to plot anything but only want some output from the data can we go about without such parts of the secion
Yes you are correct. For scan/explore you dont need any other details, except for defining a variable called "Filter". The filter variable controls and filters the the results according to your requirement.

If you had defined BUY/SELL signals, you can view them with arrows in the chart, if you click the results fetched by Explore. That will be more visually appealing and very simpler to understand the results. Hope you got my point here.

Quote:
I also need further help in generating output as i mentioned in my previous post but since no proper guidelines exist even in help file, i have asked u about it
What kind of help you need in this case? We can give the required AFL in a matter of time. But our intention is to make you learn AFL, so that you can benefit immensely from it. You needn't depend upon others. Let me know the precise help which you need in this matter.

Quote:
I have some knowledge of Visual Basic and ASP programming
I don't have any idea about these languages, and I don't know whether it will be helpful in learning AFL. But since they are programming languages, I assume that it will make you understand and learn AFL faster.

Praveen.
Reply With Quote
  #97  
Old 26th March 2007, 08:48 AM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Quote:
Originally Posted by True Data India View Post
....
When the short condition is satified , we go short but we also close (sell ) our buy position.
.....
Hi,

That is the usual case. But the Sell and Short conditions depends upon ones trading system. It can also be different, as is in Royal's case.

Praveen.
Reply With Quote
  #98  
Old 27th March 2007, 12:32 AM
Member
 
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
ume68 is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

Dear Praveen,

Pls help in a afl which tells that the next day would be a full range up day.


Regards
Reply With Quote
  #99  
Old 27th March 2007, 09:57 AM
Member
 
Join Date: May 2006
Location: Bangalore
Posts: 913
Thanks: 0
Thanked 16 Times in 2 Posts
bvpraveen is on a distinguished road
Reputation: 48
Default Re: AmiBroker formula Language

Quote:
Originally Posted by ume68 View Post
Dear Praveen,

Pls help in a afl which tells that the next day would be a full range up day.


Regards
First tell me what 'full range up day' means. I don't know about it.

Praveen.
Reply With Quote
  #100  
Old 27th March 2007, 11:28 AM
Member
 
Join Date: Feb 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
ume68 is on a distinguished road
Reputation: 20
Default Re: AmiBroker formula Language

Dear Praveen,
A full range up day means a day which opens at its low and closes at its high. Is it possible to write and afl which tells that the next day will be a full range up day.

Regards
Reply With Quote
Sponsored Links

Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads for: AmiBroker formula Language
Thread Thread Starter Forum Replies Last Post
need help on formula cmlee MetaStock 23 8th October 2007 07:55 PM
Metastock ,Metatrader & Amibroker indicator formula saji oommen MetaStock 0 4th June 2006 06:35 PM
Metastock language help Ropewalker MetaStock 4 1st November 2005 09:16 PM
TradeStation & MetaStock Formula Language bikertrader MetaStock 4 10th December 2004 01:50 PM


All times are GMT +5.5. The time now is 03:52 PM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum Rules Disclaimer & Disclosure and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2008, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com