Code Snippet : One Hour High-Low and Previous Day High Low

Here is a simple AFL code snippet to plot One Previous Day High Low and currently day One hourly high low (i.e high between 9:15a.m – 10:15a.m as per NSE timings)

Previous Day High Low AFL code

To compute Previous days high-low values we need to use TimeFrameGetPrice function as shown below. TimeFrameGetPrice basically retrive the O,H,L,C values from other timeframes and in this case it is Daily timeframe and the same values are plotted in lower timeframes.

DayH = TimeFrameGetPrice(“H”, inDaily, -1);
DayL = TimeFrameGetPrice(“L”, inDaily, -1);

Nifty Spot showing Previous day High-Low
Previous day High Low

Download Previous day High Low Amibroker AFL code

Current day’s One Hour High-Low

To get Current days’ first one hour high and low we need to use timebased functions like timenum() and finally ORBH and ORBL captures the first one hour high and low. And you can change the timings mentioned below the suit your exhchange and your requirements.

OST=091500; //Observation Start Time
OET=101500; //Observation End Time

Currtime =TimeNum(); //get current time

ob_end = Cross(TimeNum(),OET); //detect the observation end time
ob_st = Cross(TimeNum(),OST); //detect the observation start time

Highest_since = HighestSince(ob_st,H,1); //capture the 1 hour high
Lowest_since = LowestSince(ob_st,L,1); //capture the 1 hour low

ORBH = ValueWhen(ob_end ,Highest_since,1); //
ORBL = ValueWhen(ob_end ,Lowest_since,1);


Nifty Spot showing Current Day’s One Hour High-Low
One Hour High-Low

Download One hour high low Amibroker AFL code

Related Readings and Observations

  • How to Plot Bid Vs Ask Dashboard in Amibroker Here is a little Bid Vs Ask Dashboard for Amibroker users which helps to monitor the Bid-Ask Spread during live trading. In a highly liquid market the Bid Ask spread difference will be […]
  • Things You Need to Know About VWAP In finance terms, volume-weighted average price (VWAP) is defined as the ratio of the value traded to total volume traded over a particular time horizon (usually one day). It is a measure […]
  • Rotation Factor – Amibroker AFL Code Rotation Factor is a sentimental indicator used in Market Profile to Indicate who is control (Buyers/Sellers) in the market for the day. If the rotational factor prints positive values […]
  • Full Gap Open Range Strategy – Amibroker AFL Code Here is a simple Full Gap Open Range Strategy for intraday traders to trade the big gap ups and gap downs using open range breakout. And more important strategy is back-testable.


  1. Veer says

    Dear Rajandran

    Thanks for the AFL. Please tell me how to incorporate previous day close also and how to make the line thick. This will be very much hepful. same thing for hourly also please. Expecting your reply.

    Thanks & Regards,


    • says

      To incorporate previous day close along with thick lines add the following codes to your AFL. styleThick in plot function represents thicker lines

      DayC = TimeFrameGetPrice(“C”, inDaily, -1);
      Plot(DayC, “PDC”,colorBlue,styleLine|styleNoRescale|styleNoTitle|styleThick);

  2. Veer says

    Dear Rajandran

    Thanks again. I have incorporated and it comes but I want the line thickness still more. I tried to incorporate stylethick =4 but still it is thin. How to do very thick- please guide. It will be helpful.

    Thanks & Regards,


  3. Ravindra says

    Very good AFL Rajandran

    want to request just add 2 more thing if possible

    “add open and close line also of”

    its better to trade with candlestick pattern forms around these levels

  4. zain says

    I have applied the AFL but i cant see the hrly high low line on price chart…
    Can see plain price chart

  5. kashif says

    sir i need eod data for mcx from 1 jan till now for amibroker in txt file where i can get .. my getbhavcopy data downloader software didnt downloading the eod data for mcx now how to download the same if it is possible i need it for eod charts in amibroker pls guide..

  6. srini says

    dear sir,

    am planning to give 30 days trial to my clients regarding the buy and sell signal in my own statergy. what should be added to the code to protect them from viewing the formula and closing the signal exactly after 30 days of trial Kindly guide

  7. SATHISH says

    I want to create exploration based on hourly high or low afl. I want to scan the stocks that have crossed first hour high or low. Could you please help

  8. Dilip Singh chouhan says

    Dear sir .
    i am using amibroker 5.6 newar show howerly chart .
    plz help me.

    Thanks & Regards
    Dilip Singh

Leave a Reply

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