![]() |
|
| 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 ... |
|
|||||||
| Notices |
![]() |
|
|
Thread Tools |
| Sponsored Links |
|
#91
|
|||
|
|||
|
Quote:
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. |
|
#92
|
|||
|
|||
|
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. |
|
#93
|
|||
|
|||
|
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 |
|
#94
|
|||
|
|||
|
Quote:
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. |
|
#95
|
|||
|
|||
|
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 |
|
#96
|
||||
|
||||
|
Quote:
Quote:
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:
Quote:
Praveen. |
|
#97
|
|||
|
|||
|
Quote:
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. |
|
#98
|
|||
|
|||
|
Dear Praveen,
Pls help in a afl which tells that the next day would be a full range up day. Regards |
|
#99
|
|||
|
|||
|
Quote:
Praveen. |
|
#100
|
|||
|
|||
|
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 ![]() |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
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 |
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.