_SECTION_BEGIN("Price");
Plot( Close, "Close", colorGold, styleCandle);
_SECTION_END();
And I also gave you some task like : change the color of candle and the style of candle. I hope, you have able to change the candle and your code look like below :
_SECTION_BEGIN("Price");
Plot( Close, "Close", colorGold, styleBar);
_SECTION_END();
If you failed to do so no problem, copy the above code and paste it in your Formula Editor, Save As it in your ........\AmiBroker\Formulas\Custom folder. If you face any problem, pls see the AFL Code Writing : Lesson 1. I hope your chart looks like the below one if you select DSE General Index as Symbol (Pls. skip the background color):
Now if you want to change the color of bar/candlesticks like red, you know how to do it. You have to write colorRed instead of colorGold and then you have to save it. Or you commercially sell your afl code and later on your user of the afl wants to change the bar/candlesticks color, but they don't know how to write afl code. If you advice them to visit this blog to know how to change the bar color, you may not get a call from your user next time to develop another system for them.
Okay, how can we change the color without editing the code? It's easy. Just Click right button of your mouse on the chart.
You will see Parameters.... Left button click on it and you will find
Nope.... It's blank. Okay, no problem. We have to make a little change in our afl code. Okay, leave the page by clicking Ok and again right click on the chart and you will find Parameters...., Properties and then Edit Formula... Left click on Edit Formula and you will find your code.
Just write
ParamColor("Color", colorGold)
instead of colorGold. So, your final code will be :_SECTION_BEGIN("Price");
Plot( Close, "Close", ParamColor("Color", colorGold), styleBar);
_SECTION_END();
Now, Save As it. (Pls. see the AFL Code Writing : Lesson 1 if you don't know how to Save As a file and display the chart). Right Click on the chart and you will get Parameters... Click on it and you will find
Wow!!! Lots of color. Select any color and click ok. Bar color will be changed as per your change. Now your user able to change the color of bar as per their desire without knowing any code. Our job is done.
No No No No No No No. I don't want to give any Faki-zuki. Now see the explanation our newly added code :
Syntax :
ParamColor("Color", colorGold)
Meaning : ParamColor() indicates that it will be displayed in the Parameters dialog box so that our user can change the color without editing the code.
ParamColor("Color",) indicates that the name of the besides item. You may keep it blank like "". Then program automatically pick the afl name.
ParamColor("", colorGold) indicates that we have given a default color i.e. Gold color.
Its awsumly good vaiya.. Anything to get such lessons. God bless you
ReplyDeletekeep going.........nice work!
ReplyDeletenicely taught, god bless u
ReplyDelete