Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, 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. Now the recent curiosity on building Trading AI Agents.

Coral Trend Indicator – Amibroker AFL Code

1 min read

Coral Trend Indicator AFL on Nifty Future EOD charts
Coral trend AFL indicator on Nifty futures EOD chart

Coral Trend Indicator is yet another trend following indicator inspired by Tradingview Pinescript code. Code is designed to plot in PSAR style, similar to the JNSAR dots system. Green color dots represent a bullish trend. and the red dots represent a bearish trend. Coral trend applied to Nifty EOD charts as shown in the above figure.

Looks like the system is quite popular in the MT4 platform among FX traders known as THV Coral. Whatever the code does is just the indication of the trend and not a complete system though. Do your homework if you would like to build some system on top of it.

OpenAlgo: one API for 35+ Indian brokers

FREE AND OPEN SOURCE

OpenAlgo: one API for 35+ Indian brokers

Self-hosted algo trading platform. Send orders from Python, AmiBroker, TradingView, Excel or a no-code flow through one consistent API.

  • Unified REST and WebSocket API
  • Works with AmiBroker, TradingView, ChartInk and Excel
  • Sandbox mode to test before going live
Get OpenAlgo →by Marketcalls

Nifty Future 15min Charts
NF 15min

Amibroker AFL Code – Coral Trend Indicator

_SECTION_BEGIN("Coral Trend Indicator");
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, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 


sm = Param("Smoothing Period",21,2,40,1);
cd = Param("Constant D",0.4,0.1,2,0.1);

SetBarsRequired(ceil(3.5 * sm)) ;   // minimum lookback required for stability //

di = (sm - 1.0) / 2.0 + 1.0;
c1 = 2 / (di + 1.0);
c2 = 1 - c1;
c3 = 3.0 * (cd * cd + cd * cd * cd);
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd);
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd;

src = Close;
i1=0;
i2=0;
i3=0;
i4=0;
i5=0;
i6=0;


for(i=1;i<BarCount;i++)
{

i1[i] = c1[i]*src[i] + c2[i]*i1[i-1];
i2[i] = c1[i]*i1[i] + c2[i]*i2[i-1];
i3[i] = c1[i]*i2[i] + c2[i]*i3[i-1];
i4[i] = c1[i]*i3[i] + c2[i]*i4[i-1];
i5[i] = c1[i]*i4[i] + c2[i]*i5[i-1];
i6[i] = c1[i]*i5[i] + c2[i]*i6[i-1];

}

bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3);

color = IIf(bfr>Ref(bfr,-1),colorGreen,colorRed);

Plot(bfr,"Coral Trend Indicator", color,styleDots|styleNoLine|stylethick);


_SECTION_END();
Marketcalls Elite Traders Club

MEMBERSHIP

Marketcalls Elite Traders Club

Every Marketcalls course and live mentorship in one membership: 127 courses and 2,500+ hours of learning.

  • Market Profile, Orderflow, AFL, Pine Script and Python
  • Live mentorship and TradEdge trading room
  • Premium tools and the Elite Slack community

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, 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. Now the recent curiosity on building Trading AI Agents.

12 Replies to “Coral Trend Indicator – Amibroker AFL Code”

  1. Hi, I found in Ami 5.60.2 that when you zoom in to a chart the red and green dots are shifting. In such a case the indicator is not very reliable. Brgds, CArnot

  2. Hi,

    The download link gives the same code with repainting problem. Please update the link. Enjoy, CArnot.

  3. hello sir i am regular reader and follower of your AFL and POSTs lot of thanks
    sir my humble Request sir please prepaire to this AFL in to MULTI TIME FRAME ( Not MTF DashBoard ) means when we select 5 min chart but indicator play like 15 min s Data based , and 15 min chart like 60 min …………,
    sir i found like this supertrend in MQ4 but not in Amibroker so please ……………prepaire this AFL ( Coral Trend Indicator) in MTF i hope response possitively thankyou sir

  4. Yes It would be excellent if Coral can be coded for multi time frame.
    Which means the buy signal would be generated in 5 min chart when 15 min chart turns green and in reverse sell would be signalled in conjunction with 15 mind chart or 30 mins chart.
    Even if there is a way to notice coral trend higher time frame indicator in lower time frame it would be excellent.

  5. Not better use this function instead looping.

    function T3( Price, T3Periods, s )
    {
    e1 = AMA( Price, 2 / ( T3Periods + 1 ) );
    e2 = AMA( e1, 2 / ( T3Periods + 1 ) );
    e3 = AMA( e2, 2 / ( T3Periods + 1 ) );
    e4 = AMA( e3, 2 / ( T3Periods + 1 ) );
    e5 = AMA( e4, 2 / ( T3Periods + 1 ) );
    e6 = AMA( e5, 2 / ( T3Periods + 1 ) );
    C1 = -s ^ 3;
    C2 = 3 * s ^ 2 * ( 1 + s );
    C3 = -3 * s * ( s + 1 ) ^ 2;
    C4 = ( 1 + s ) ^ 3;
    T3Result = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3;
    return T3Result;
    }

Leave a Reply

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