Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

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

54 sec read

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

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

How to Automate your Strategy just by Adding Two…

Since the start of Algomojo, we are focusing on one thing how to simplify the Automated Execution controls so that traders can easily convert...
Rajandran R
2 min read

[Free Webinar] Starting Amibroker AFL Coding Right from the…

Interested in Creating your own indicators/Buy or Sell Trading System. Learn How to build your own trading system using Amibroker. If you are new...
Rajandran R
27 sec read

Angel Broking Multi-Client Amibroker Trading Module

Got frequent requirements from Angel Broking Customers to automate Amibroker based trading system where one single generation from charts could punch orders in multiple...
Rajandran R
6 min read

24 Replies to “Code Snippet : One Hour High-Low and Previous Day…”

  1. 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

    1. 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. 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. 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. Hi,
    I have applied the AFL but i cant see the hrly high low line on price chart…
    Can see plain price chart

  5. 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. 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. sir i want to scan stocks when they cross previous day high or low.

    please provide required afl sir

  8. 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

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

    Thanks & Regards
    Dilip Singh

  10. Dear Sir,

    Can you set parameters if I want to close all Open trades by intraday (say 3.15 pm )

    Can you set code and update me ?

    Thanks

  11. Sir,
    Regarding AFL for previous day high-low indicator, I am in need of an indicator that plots PDH and PDL line excluding tail of PDH and PDL.
    How to incorporate it in AFL.

    Regards,

    Manish

  12. Hello Rajendra,

    May I request you to modify this AFL to display historic 1 hour high and low also please.

    Thanks
    NK

  13. Hi Rajandran ,

    how to plot high and low of a particular interval say interval of 13:00;00 to 15;30;00 of previous day on the current day.
    it would be of great help. Thanks

  14. I m using Amibroker 5.90 version. Previous day HL is displayed but today open range High Low is not displayed. Can you please clarify me, is it version issue or any other thing.

Leave a Reply

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