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.

52 Week High and Low Stock Scanner – AFL Code

34 sec read


 
Here is a simple afl code which scans for 52 week High and Low in Amibroker software.

Following Filter Parameters used:

HI = Close > Ref(HHV(High,260),-1);
LW = Close < Ref(LLV(Low,260),-1);

i.e scan the list of stocks whose Last Trading Price(Close value) should be greater than the Higher High value of past 260 trading sessions/Candles,which is nothing but 52 week High or Last Trading Price(Close value) should be lesser than the Lower Low value of past 260 trading sessions/Candleswhich is nothing but 52 week High

Here the value 260 is choosed as a approximation value that out of 365 days in a year, Saturdays and Sundays alone contribute to 52×2=104 days. So as an approximation 260 is taken as a rounded value to find out 52 Week High/Low from the list of stocks.

Download 52 Week High/Low AFL here – While saving save this file as .afl file

Scanning results from my NSE EOD Pack

52 Week High and Low NSE Stocks

TickerDate/Time52 Week High52 Week LowClose
AGCNET8/20/201001226.05
BAJAJCORP8/20/201001726.5
HBLPOWER8/20/20100124.7
HCC8/20/20100164.35
JAYSREETEA8/20/201001159.95
KLGSYSTEL8/20/20100192.6
REDINGTON8/20/20100182.3
TELEDATAIT8/20/2010011.65
AARVEEDEN8/20/20101091.45
ASIL8/20/2010104.1
ATUL8/20/201010135.45
BAJAUTOFIN8/20/201010635
BASML8/20/201010146.75
CLNINDIA8/20/201010719.5
CORPBANK8/20/201010628.85
DCB8/20/20101054.75
EXCELCROP8/20/201010259.9
EXIDEIND8/20/201010147.6
GEINDSYS8/20/201010161.65
HDFCMFGETF8/20/2010101860.95
HITECHGEAR8/20/201010207.65
ICIL8/20/20101019.45
INDSWFTLAB8/20/20101093.95
INDSWFTLTD8/20/20101039.45
IRB8/20/201010303
JBCHEPHARM8/20/201010111
JETAIRWAYS8/20/201010818.25
JINDALPOLY8/20/201010637.4
JUBLFOOD8/20/201010538.9
KARURVYSYA8/20/201010681.5
LAKSHVILAS8/20/201010125.4
MALWACOTT8/20/20101056.05
NATCOPHARM8/20/201010221.9
NSEMIDCAP8/20/2010108930.85
ORIENTBANK8/20/201010444.65
PATSPINLTD8/20/20101015.05
RPGLIFE8/20/201010110.35
RSWM8/20/201010152.7
SAREGAMA8/20/201010157.35
SARLAPOLY8/20/201010140.1
SHIVAMAUTO8/20/201010145.5
SKSMICRO8/20/2010101215.9
SOBHA8/20/201010387.6
SPMLINFRA8/20/201010234.5
SURAJDIAMN8/20/20101066.85
SURYAPHARM8/20/201010229.05
SUTLEJTEX8/20/201010227.7
TTL8/20/20101039.1
WOCKPHARMA8/20/201010247.15
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.

Algomojo Index Straddle/Strangle Execution Module with Intraday Stoploss

This tutorial focus on how to automate your index straddle/strangle strategy with intraday stop-loss levels with time-based entry and exits using Algomojo Platform and...
Rajandran R
7 min read

Learn How to Login into Algomojo Account using Amibroker

In the last tutorial, we learn how to automate the algomojo login process and in this video tutorial, we are going to learn with...
Rajandran R
1 min read

Amibroker Execution Module – Hedged Index Futures for Directional…

In the last tutorial, we learn the importance of Hedging Futures Position with OTM Options for Reduced Margin. This tutorial focus on how to...
Rajandran R
14 min read

21 Replies to “52 Week High and Low Stock Scanner – AFL…”

  1. Dear Rajendran,

    I am looking for a AFL that extract Open,High,Low,Close and Volume for hourly / half-hourly time frame during intra-day. It shall be for all scripts that is available in Amibroker currently. The extraction shall be exported into an Excel file. Do you have / use such AFL? If so, please give the link.

    Thanks & Regards,

    Veer

  2. thanks for such code when i add this afl and scan it shows error “MISSING BUY/SELL VARIABLE ASSIGNMENT” can anybody tell how to solve this error. as i have just started using ami broker.

  3. Dear Raj,

    sometime back,u wrote afl for intraday trading using 5 high and low ema’s. not able to trace that now..cld u post the link please

    tks n best
    sri

  4. add to that rsi and then follow the rising rsi from 52wk low and declining rsi on 52 wk high rest you can figure out

  5. Dear Rajendran,

    Can you pls provide me the link of AFL code for Point & Figure charting with box size as variable(i.e user can change the box size).

    Regards,

    Veer

  6. Thanks Rajendran,

    Your website is really informational and there is always a new thing to learn about whenever I visit it.

    Keep up the good work and Thanks a lot.
    Gopikrishna.

  7. Thanks for the code. Is it possible to modify the code such that the Number of new highs minus the number of new lows (NH-NL)ca be plotted as a histogram in a separate window.

  8. Dear Rajandran
    Thx for your excellent work to help the trading community.
    Understand that “Pin bar candlle” is also an excellent indicator to trade.
    May I, therefore request you to provide a scan for the same.
    It would be ideal if it is added to the existing candle identication AFL already avlbl.
    Thx again
    Brgds
    Ravi

  9. Dear Rajendra Sir,

    I found one very interesting thing at below link

    http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:high-low_index

    Which is The High-Low Index is a breadth indicator based on Record High Percent

    Calculation of this index is as below

    Record High Percent = {New 52 week Highs / (New 52 week Highs + New 52 week Lows)} x 100

    High-Low Index = 10-day SMA of Record High Percent.

    Sir This is very good overlay indicator in stockcharts but only give SP500 and other foreign index.
    Can you please convert this into afl and post in marktcalls. There is no such indicator on the web in any charting software.

  10. Dear Rajendra Sir,
    i am new to alf plz let me know alf for BUY = LAST PRICE > PREVIOUS 2 CANDLE HHV WITH STOPLOSS OF 1% AND TRALING STOPLOSS %

  11. Hello Sir,

    I am trying to create a multi year high screener.

    Issue 1:
    Is there a way to compare between 52W high and 104high. If the answer is Yes compare with 156 weeks rates.

    Issue 2:
    If the price cross above the price which was high 3 years back but below price which is 2 years high eg
    2014 price 100 2015 price 150 today if it cross 100 we want it to be highlighted.

    Your guidance in the matter will be highly useful.

Leave a Reply

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