How to color code charts and simplify chart reading using amibroker AFL?

How to color code charts and simplify chart reading using amibroker AFL?

Welcome to Episode 12 of Algo Trading Series from MarketSecrets.

Instead of going through a strategy, for a change, we are going to just play around the AFL in this episode. We are going to do a simple thing in this episode – Color coding.

We are going to use the AFL to color code the chart based on the different indicators and the value of those indicators at a specific point in time.

We are taking RSI as the indicator here and we are going to color the candles in chart as per RSI value. If candle color is red then RSI is in bear zone and if candle color is green the RSI is in bull zone.

We can drill down this into different zones and we can color code it based on our linkings.

 

After all these episodes, you would have gotten familiarized with most of the scripts used in this AFL.

This is the only line that is different.

BarColor = IIf( (RSI_Value > 60 AND RSI_Value < 75), colorRGB(128, 255, 0), ……………………………….))))))))))

If you know simple programming, you would easily understand. This line will decide the color of the candle based on the value of RSI at that moment. We have splitted this into different ranges, you can even use just 2-3 colors.

 

You may ask, what is the use of these kind of stuffs. Simple, if you are in the Trading business for a longtime, you would already know trading is a boring job. Colour charts will simplify out work during intraday trading. We can color the candles in such a way that is we see a specific color in the chart, it indicates, we are getting closer to our entries and we need to be alert.

This will greatly reduce our work and also make the charts colourful. This will definitely come in handy in reducing the screentime if you are an active trader and trading everyday for 6-8 hours. Having multiple screens will simplify this even further.

You can play around the RSI setting and colors, you can also make similar colourful charts for any of the indicators you use as well.

 

So, Do give this a try and play around it. Let us know in case of any issues.

If you want any specific strategy to be scripted and discussed as part of the forthcoming episodes, drop the details in the comments section of the video, we will definitely consider it.

 

Script:

_SECTION_BEGIN(“RSI Candle”);

Period = Param(“RSI Period”, 14, 7, 50, 1);

RSI_Value = RSI(Period);

BarColor = IIf( (RSI_Value > 60 AND RSI_Value < 75), colorRGB(128, 255, 0),

IIf( (RSI_Value > 75 AND RSI_Value < 85), colorOrange,

IIf( (RSI_Value > 85), colorRed,

IIf( (RSI_Value > 50 AND RSI_Value < 55), ColorRGB(185,255,185),

IIf( (RSI_Value < 50 AND RSI_Value > 45), colorPink,

IIf( (RSI_Value <40 AND RSI_Value > 25), colorRed,

IIf( (RSI_Value <25 AND RSI_Value > 15), colorGreen,

IIf( (RSI_Value < 15), colorRGB(128, 255, 0), ColorRGB(255,255,128)))))))));

_SECTION_END();

 

_SECTION_BEGIN(“Price”);

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat(“{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot( C, “”, BarColor, styleCandle);

_SECTION_END();

 

For more details and examples, checkout the video:

https://youtu.be/dB3-gqV_Cm4

 

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!