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)

Modified 5 EMA High-Low AFL code

1 min read

I’ve received numerous complaints from some Amibroker users regarding issues with the 5 EMA High-Low AFL code. Consequently, I’ve made several corrections and modifications to address these concerns.

The main adjustment involves resolving the problem of continuous and excessive buy or sell signals appearing on the charts. In the updated version, I’ve integrated the EXREM function to remove these signals, while retaining the original buy and sell conditions—namely, buying when the close is above the 5 EMA high and selling when it’s below the 5 EMA low.

Additionally, I’ve introduced an interactive dashboard feature that conveniently tracks the 5 EMA High-Low values, providing users with a clearer overview of the data

Buy = Cross(C,EMA( High , 5 )); 
Sell = Cross(EMA( Low , 5 ),Close); 

Buy = ExRem( Buy, Sell ); 
Sell = ExRem( Sell, Buy );

Preferred timeframe
Mostly suitable to work at higher timeframes like Daily, Monthly, Weekly

Modified 5EMA High - Low Dashbord

Nifty 5 EMA High-Low Weekly Charts

The Nifty Weekly charts display buy or sell signals based on the 5EMA High-Low strategy. Presently, Nifty is in a long-term buy mode according to the weekly timeframe, with support from the 5 EMA low around the 5495 zone. A close below this level may indicate a potential downtrend in the long term.

5EMA High-Low AFL with Dashboard Style

//Coded by Rajandran R
//Webiste : www.marketcalls.in

_SECTION_BEGIN("5 EMA High-Low");
SetChartOptions(0,chartShowArrows|chartShowDates);

X0 = 10;
Y0 = 20;


procedure DrawData (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
	GfxSetOverlayMode(0);
	GfxSelectFont("Verdana", 8.5, 700);
	GfxSetBkMode(1);
	GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
	GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}


Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
Buy = Cross(C,EMA( High , 5 ));
Sell = Cross(EMA( Low , 5 ),Close);

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy ); 
PlotShapes(IIf(Sell==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);
Plot( EMA( Low,5), "",colorred);
Plot( EMA( High,5), "",colorred);


DrawData (Name(), X0, Y0, X0+150, Y0+20, colorGrey40, colorGrey40);
DrawData (Date(), X0+155, Y0, X0+320, Y0+20, colorGrey40, colorGrey40);
DrawData ("Open : " + Open, X0+325, Y0, X0+450, Y0+20, colorGrey40, colorGrey40);
DrawData ("Close : " + Close, X0+455, Y0, X0+580, Y0+20, colorGrey40, colorGrey40);
DrawData ("High : " + High, X0+585, Y0, X0+710, Y0+20, colorGrey40, colorGrey40);
DrawData ("Low : " + Low, X0+715, Y0, X0+840, Y0+20, colorGrey40, colorGrey40);
DrawData ("5EMA(High) : " + EMA(H,5), X0+845, Y0, X0+1000, Y0+20, colorGrey40, colorGrey40);
DrawData ("5EMA(Low) : " + EMA(L,5), X0+1005, Y0, X0+1150, Y0+20, colorGrey40, colorGrey40);
 
_SECTION_END();

Powergrid and IDEA – Two stocks to watch for Very Long Term

The monthly 5EMA high-low charts for Powergrid and IDEA are displayed. Both charts generated a buy signal last month. Powergrid’s long-term trend shifted to a buy mode nearly 12 months later, while IDEA took 5 months to do so. Presently, both IDEA and Powergrid are trading above the 5EMA high zone, with the 5EMA monthly low zone serving as trailing long-term supports at Rs 67 and Rs 100 respectively. Long-term investors may find focusing on these stocks beneficial for their investment portfolios.

Powergrid Monthly chart

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)

Reversal Finder – Tradingview to Amibroker AFL Code Conversion

Reversal Finder is designed to identify potential reversal signals in a stock's price action. It highlights specific bars that meet the criteria for a...
Rajandran R
2 min read

CM Williams VIX FIX Pinescript to Amibroker AFL Conversion

Thought of converting some of the top-rated pinescript codes to Amibroker AFL code. So started with CM Williams VIX FIX with 51,000+ ratings for...
Rajandran R
1 min read

5 Paisa Webhook – Amibroker Button Trading Module

In this tutorial, we will be using 5 Paisa Webhooks to Send Orders using the Amibroker Button Trading Module. This Button trading module provides...
Rajandran R
3 min read

14 Replies to “Modified 5 EMA High-Low AFL code”

  1. do you provide us candle graph chart with different EMA (3,13,34) for intraday tradeing.if is it possible then send detail site address, so we can study in detail. We are searching for same to evaluate the trend of further movement of a market of a particular of a company. Waiting your reply, till time thanking you.

    your’s

    MANAN JHAVERI – MUMBAI – INDIA

    1. @Manan Jhaveri

      You can check out NSETracker for intraday realtime charts for nifty with parameters 13,34,55 EMA we had stopped using
      3min EMA as 3min EMA can be roughly taken as the candle itself

  2. sir ur broco live update which site sir pay chart i want sir. then sir indicator i see zigzag indicator so i want buy sell indicator u creat and give me sir when ever zigzag come next candle buy sell indicator creat me sir how much cost u tell sir . sir see 30minites 60 minites timeframe see sir

  3. thank and see mail give me mail sir what i telling u no sir 30 minites 60 minities u see zigzag come then buy sell signal u creat sir u r thise filed u r graet sir see then u give my mail sir.

  4. Hi,
    I am trying to plot 2 EMAs using AFL, one is from 5 min and other is from 60 min.
    I don’t think Amibroker is plotting MA from 60 Timeframe properly, it shows up as a step where as I was expecting it to be a smoothish one, Here is the code and the result is shown in the image.
    Am I missing something here? Can you please help?
    Look forward to your response and help.
    thanks a ton in advance.

    CODE
    TimeFrameSet( in5Minute ); // switch to 5 minute frame

    /* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */

    ma5_13 = MA( C, 13 );

    TimeFrameRestore(); // restore time frame to original

    TimeFrameSet( inHourly ); // switch now to hourly

    mah_9 = EMA( C, 9 ); // 9 bar moving average from hourly data

    TimeFrameRestore(); // restore time frame to original

    // plot expanded average

    Plot( TimeFrameExpand( ma5_13, in5Minute), “13 bar moving average from 5 min bars”, colorRed );

    Plot( TimeFrameExpand( mah_9, inHourly), “9 bar moving average from hourly bars”, colorBlue );

  5. Please see the AFL code below and attached image, i was expecting the MA from 60 min TF to be smoothened just like other EMA is there anything wrong in the code? Please help.

    TimeFrameSet( in5Minute ); // switch to 5 minute frame

    /* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */

    ma5_13 = MA( C, 13 );

    TimeFrameRestore(); // restore time frame to original

    TimeFrameSet( inHourly ); // switch now to hourly

    mah_9 = EMA( C, 9 ); // 9 bar moving average from hourly data

    TimeFrameRestore(); // restore time frame to original

    // plot expanded average

    Plot( TimeFrameExpand( ma5_13, in5Minute), “13 bar moving average from 5 min bars”, colorRed );

    Plot( TimeFrameExpand( mah_9, inHourly), “9 bar moving average from hourly bars”, colorBlue );

  6. Sir, thanks for ur 5ema high alert afl. please help me to get pop up window . so that we will get pop up alert with stock name in different time frame

Leave a Reply

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