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);

Plot(ORBH,””,colorGreen,styleDots);
Plot(ORBL,””,colorBlue,styleDots);

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 […]
  • Last Five Trades Result Dashboard – AFL code Here is simple visualization to look into the past five trades result and plot the values over the chart which gives a quick view on how the strategy performed in the last five trades. In […]
  • Simple Smoothed RSI Crossover Strategy Here is the simple smoothed RSI crossover strategy can be practiced on higher timeframes especially with daily timeframes with controlled risk. It catches the big trends and gets little […]
  • Intraday Gap Up and Gap Down – Amibroker Strategy Strategy is very simple. when the market open with gap up and at the same time ,it crossed the previous day high then it should be considered as strong buy. When the market open with gap […]

Comments

  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,

    Veer

    • 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,

    Veer

  3. Ravindra says

    Very good AFL Rajandran

    want to request just add 2 more thing if possible

    “add open and close line also of p.day”

    its better to trade with candlestick pattern forms around these levels

  4. zain says

    Hi,
    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

Leave a Reply

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