Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Colour Changing Candlesticks

40 sec read

Here is a simple demonstration about how to vary the color of the according to our strategy. For demo purpose i had used the ADX Indicator which uses positive and
negative directional indicators +DI and -DI and in amibroker terms it is represented as PDI() and MDI(). And we are not going to concentrate on ADX in this demo.


[wp_ad_camp_5]

 
Sample code is shown below

_SECTION_BEGIN(“Price”);
_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 ));
range = Param(“Periods”, 14, 2, 200, 1 );
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, “Close”, IIf( PDI(range) > MDI(range), ParamColor(“Up Color”, colorGreen ),
ParamColor(“Down Color”, colorRed )), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
_SECTION_END();

A green candle will be plotted if +DI is greater than -DI which denotes Uptrend and Red candle will be plotted if +DI is lesser than -DI which denotes downtrend and the following code does all the magic in toggling the colors of the candle.

Plot( C, “Close”, IIf( PDI(range) > MDI(range), ParamColor(“Up Color”, colorGreen ),
ParamColor(“Down Color”, colorRed )), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Plotting Day Wise Equity Curve using Amibroker

We know that Amibroker provides an equity curve for the whole strategy. Is there a way where we can build a simple Day Wise...
Rajandran R
1 min read

Simple Open Range Breakout Trading System with Exploration –…

Opening Range is very often a measure of security high and low generally monitored by breakout traders to gauge the sentiment of the market....
Rajandran R
5 min read

Range Filter – Trading Strategy – Amibroker – Better…

Range Filter is a non-ATR-based trend following strategy inspired by Tradingview Pinescript coder - DonovanWall. According to him, Range Filter is an experimental study...
Rajandran R
4 min read

6 Replies to “Colour Changing Candlesticks”

  1. hi raj sir

    i hope u must on holiday keep it to maximum sir

    but i do urge to post one note of afl regarding how to use AUX1 n AUX2 on charts, scan and exploration in whole as an array in amibroker 5.30 as i searched alot for it but didnt found any solution to it and many people i think must be searching for it
    and thomas provided that by using OLE language, COM or addtocomposite we can access it.
    but i tried it far as could but not able to make it
    plz sir due luk at it when u get back from holiday
    GOD BLESS U!

    regards
    ankit

  2. Sir

    I copied the code given on this page (http://www.marketcalls.in/afl-code/colour-changing-candlesticks.html) exactly as it is

    But it is showing error.

    Pl help me.

    This is what my code looks like :-

    _SECTION_BEGIN(“Price”);
    _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 ));
    range = Param(“Periods”, 14, 2, 200, 1 );
    SetChartOptions(0,chartShowArrows|chartShowDates);
    Plot( C, “Close”, IIf( PDI(range) > MDI(range), ParamColor(“Up Color”, colorGreen ),
    ParamColor(“Down Color”, colorRed )), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
    _SECTION_END();

    Plot( C, “Close”, IIf( PDI(range) > MDI(range), ParamColor(“Up Color”, colorGreen ),
    ParamColor(“Down Color”, colorRed )), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );

    1. The error is due to formatting of the __*Quotation*__symbols, Change all the quotations symbols manually and re-apply, the error would not show up.

      _SECTION_BEGIN(“Price”);
      _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 ));
      range = Param(“Periods”, 14, 2, 200, 1 );
      SetChartOptions(0,chartShowArrows|chartShowDates);
      Plot( C, “Close”, IIf( PDI(range) > MDI(range), ParamColor(“Up Color”, colorGreen ),
      ParamColor(“Down Color”, colorRed )), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
      _SECTION_END();

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More