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)

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

[wp_ad_camp_5]

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

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

[Webinar] Understanding and Mitigating Curve Fitting in System Trading

"Understanding and Mitigating Curve Fitting in System Trading"! This dynamic session aims to equip novice to intermediate traders, quantitative analysts, and financial engineers with...
Rajandran R
1 min read

P-Signal Strategy Long Only Strategy – Amibroker AFL Code

This tutorial provides an overview of the P-Signal reversal strategy, a quantitative trading strategy that utilizes statistical parameters and error functions to generate probabilistic...
Rajandran R
2 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