This function is very simple and sometime useful. You can use this function if you need to color an indicator with a color when the indicator is ascending and with another color if the indicator is descending. The AFL (Amibroker Formula Language) function code is:
function ColoredIndicator( Indicator, UpColor, DnColor )
{
CI = Null;
for ( i = 1; i < BarCount; i++ )
if ( Indicator[i] > Indicator[i-1] )
CI[i] = UpColor;
else
if ( Indicator[i] < Indicator[i-1] )
CI[i] = DnColor;
else
CI[i] = CI[i-1];
return CI;
}
|
For example you can use it to color the
SuperTrend indicator that I coded in my
previous post:
#include_once ".\Formulas\Custom\Functions\SuperTrend.afl";
#include_once ".\Formulas\Custom\Functions\ColoredIndicator.afl";
ST = SuperTrend( 10, 3 );
ColorArray = ColoredIndicator(ST, colorGreen, colorRed);
Plot( ST, "SuperTrend", ColorArray);
|
You need to customize the #include paths, the result is something like this
Comments
Post a Comment