Now lets discuss how to plot Price in your Amibroker chart using AFL.
It is very important to show price action in your chart. Here this simple code will show price in your chart.
Every Amibroker AFL starts with a section. A section is nothing but a block, that contains your AFL codes. Syntax of your AFL section is like this
_SECTION_BEGIN("Name of the section");
// Your Code
_SECTION_END();
You can use any name your like to identify your section purpose.
Comment Line in AFL code starts with "//". If you wish to make comment of your logic or code purpose then put a "//" before that line.
Use /* ....... */ as block commnet. It will make multple lines comment.
Sample
//This is a comment line
/* This is start of our comment
second line of comment
third line
.
.
.
End of my comments */
Now take an example
_SECTION_BEGIN("price section");
//Buy Logic AFL
Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
//Sell logic for AFL
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));
_SECTION_END();
Basic way,
_SECTION_BEGIN("price section");
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Very Basic black and White candlestick chart. Boring!!!
Lets do some different things here.
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorRed, styleBar );
_SECTION_END();
Red color Bar chart.
Ok, now what I have done here? I have used "C" as closing price. But two things that we can change, that is "colorRed" and "styleBar". Lets change them as we want,
Styles:
styleCandle
styleLine
styleBar
Colors:
colorRed
colorBlack
colorYellow
colorGreen
ColorWhite
etc
So lets take some Examples,
Sample 1
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorGreen, styleBar );
_SECTION_END();
Sample 2
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorYellow, styleLine );
_SECTION_END();
Solid bar price bar
_SECTION_BEGIN("Debarghya: AFL Coding");
SetBarFillColor( IIf( Close > Open, colorWhite, colorBlack ) );
Plot(C, "Price", colorRed, styleCandle );
_SECTION_END();
Debarghya Mukherjee
Mobile: (+91)-9038787021
Email: debarghya_mkr@yahoo.com
It is very important to show price action in your chart. Here this simple code will show price in your chart.
Every Amibroker AFL starts with a section. A section is nothing but a block, that contains your AFL codes. Syntax of your AFL section is like this
_SECTION_BEGIN("Name of the section");
// Your Code
_SECTION_END();
You can use any name your like to identify your section purpose.
Comment Line in AFL code starts with "//". If you wish to make comment of your logic or code purpose then put a "//" before that line.
Use /* ....... */ as block commnet. It will make multple lines comment.
Sample
//This is a comment line
/* This is start of our comment
second line of comment
third line
.
.
.
End of my comments */
Now take an example
_SECTION_BEGIN("price section");
//Buy Logic AFL
Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
//Sell logic for AFL
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));
_SECTION_END();
I used out last post buy and sell logic.
Now we wants to display price over our chart.
_SECTION_BEGIN("price section");
Plot( Close, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Very Basic black and White candlestick chart. Boring!!!
Lets do some different things here.
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorRed, styleBar );
_SECTION_END();
Red color Bar chart.
Ok, now what I have done here? I have used "C" as closing price. But two things that we can change, that is "colorRed" and "styleBar". Lets change them as we want,
Styles:
styleCandle
styleLine
styleBar
Colors:
colorRed
colorBlack
colorYellow
colorGreen
ColorWhite
etc
So lets take some Examples,
Sample 1
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorGreen, styleBar );
_SECTION_END();
Sample 2
_SECTION_BEGIN("Debarghya: AFL Coding");
Plot(C, "Price", colorYellow, styleLine );
_SECTION_END();
Solid bar price bar
_SECTION_BEGIN("Debarghya: AFL Coding");
SetBarFillColor( IIf( Close > Open, colorWhite, colorBlack ) );
Plot(C, "Price", colorRed, styleCandle );
_SECTION_END();
Debarghya Mukherjee
Mobile: (+91)-9038787021
Email: debarghya_mkr@yahoo.com
Thanks for sharing valuable information, your writing skills are very good just like Automaticbuysell.com. It is the most demanding company that delivers some Automated Intraday Strategy that will take your trading to the next level.
ReplyDelete