Tuesday, October 24, 2017

Amibroker AFL For Previous Day High Low Close Levels

Previous day High Low and Close Levels are very important reference points for intraday traders. Many traders call them as Yesterday levels, Last day levels also. In Amibroker charts, most intraday traders use these levels by marking them manually through a horizontal line. Amibroker AFL for previous day high low close levels will automatically plot these levels on current day's intraday chart. This Amibroker AFL for previous day high low close levels will plot the levels only on current day's chart so there will be no clutter.

Simply three lines of previous day high , previous day low and previous day close will be plotted. The colour red line is previous day high, the clour green is previous day low and the colour light grey is previous day close.

You may also like: Top 10 Amibroker AFL

amibroker afl for previous day high low close levels
Previous Day High Low Close Levels Chart

Download Amibroker AFL For Previous Day High Low Close Levels

26 comments:

  1. how to extend this horizontal line both side? and display value?

    ReplyDelete
    Replies
    1. I am giving a code below which is different from the above code.

      Apply the below given code through the Formula Editor & you will get text written Previous day OHLC & also the values.

      Code:-

      Plot(TimeFrameGetPrice( "H", inDaily, -1 ),"PDH",colorBlue,styleThick);
      PlotText("High",BarCount,LastValue(TimeFrameGetPrice( "H", inDaily, -1 ),True),colorBlue);
      Plot(TimeFrameGetPrice( "L", inDaily, -1 ),"PDL",colorRed,styleThick);
      PlotText("Low",BarCount,LastValue(TimeFrameGetPrice( "L", inDaily, -1 ),True),colorRed);
      Plot(TimeFrameGetPrice( "O", inDaily, -1 ),"PDO",colorLightGrey,styleLine);
      PlotText("Open",BarCount,LastValue(TimeFrameGetPrice( "O", inDaily, -1 ),True),colorLightGrey);
      Plot(TimeFrameGetPrice( "C", inDaily, -1 ),"PDC",colorDarkGrey,styleLine);
      PlotText("Close",BarCount,LastValue(TimeFrameGetPrice( "C", inDaily, -1 ),True),colorDarkGrey);

      Delete
  2. Dear Aryan,

    First of all thank you for the wonderul AFL's you keep posting.

    I am wondering if you do have an AFL code which could plot horizontal lines at the highest price and lowest price of the last 3 days.

    For ex :

    Nifty
    Day 1, High = 10000, Low = 9950
    Day 2, High = 10025, Low = 9975
    Day 3, High = 10030, Low = 10000

    On Day 4, the AFL could two horizontal lines, one at the highest price of the last 3 days, i.e. 10030 and the other at the lowest price of the last three days, i.e. 9950.

    Appreciate you help.

    Thanks
    NK

    ReplyDelete
    Replies
    1. Hi Nayan,

      Thanks for your comment.

      Okay, check back in 3-4 days, I will try to post such AFL.

      Happy Trading !!

      Aryan.

      Delete
  3. Hello Aryan,

    Tried coding this last night.
    I think it works, may I request you to validate please whenever you do find sometime.

    H2 = TimeFrameGetPrice("H", inDaily, -2); // yesterdays high
    L2 = TimeFrameGetPrice("L", inDaily, -2); // low

    H3 = TimeFrameGetPrice("H", inDaily, -3); // yesterdays high
    L3 = TimeFrameGetPrice("L", inDaily, -3); // low

    x = IIf( H1 > H2, H1, H2 );
    HA = IIf(x > H3, x, H3);

    y = IIf( L1 < L2, L1, L2 );
    HL = IIf(y < l3, y, l3);

    Sorry if this isnt the way to code this, but I ain't a coder, just trying my hands on something interesting.

    Thanks
    NK

    ReplyDelete
    Replies
    1. Hi Nayan,

      I have posted the AFL which plots the 3 Day Highest High & Lowest Low Values & lines on the Chart.

      Link Under:

      http://tradecatcher.blogspot.in/2017/07/3-day-highest-high-breakout-lowest-low.html

      Happy Trading !!

      Delete
  4. Hi Aryan,

    Please discard my previous comment. I was able to get the current day open price by modifying a very minor thing in your original code -

    _SECTION_BEGIN("PreDay HLC");
    function CDL( array )
    {
    doy = DayOfYear();
    Lastdoy = doy == LastValue( doy );
    Dayline = array * Lastdoy;

    return IIf( Dayline, Dayline, Null );
    }

    //TIME FRAME CALCULATION
    H1 = TimeFrameGetPrice( "H", inDaily, -1 ); // yesterdays high
    L1 = TimeFrameGetPrice( "L", inDaily, -1 ); // low
    C1 = TimeFrameGetPrice( "C", inDaily, -1 ); // close
    DayO = TimeFrameGetPrice("O", inDaily); // current day open

    //PLOTS
    Plot( cdl( H1 ), "", colorRed, styleLine + styleThick + styleNoRescale + styleNoLabel );
    Plot( cdl( L1 ), "", colorBrightGreen, styleLine + styleThick + styleNoLabel );
    Plot( cdl( C1 ), "", colorBlue, styleLine + styleNoRescale + styleNoLabel );
    Plot(cdl( DayO ), "", colorWhite, styleLine + styleNoRescale + styleNoLabel );
    _SECTION_END();


    Kindly look into the intraday volume breakout afl/exploration request that i have posted couple of days back.


    Thank you and Happy Trading !

    Jaspreet

    ReplyDelete
    Replies
    1. Hi Jaspreet,

      Good to know you included the Open price in the AFL as per your requirement. Regarding Volume Breakout AFL , be assured if it is done it will be surely published by me & I am trying to find time from my crunching schedule to have a look at the same.
      Happy Trading !!

      Aryan.

      Delete
  5. Thanks Aryan , for considering my request. Your effort in running this useful blog is highly appreciable !

    Happy trading to you too !

    Jaspreet

    ReplyDelete
    Replies
    1. Hi Jaspreet ,

      As a starting point check this code which I am giving below and see if you can do some modification as per your requirements.

      Filter = V > 10*Ref(V,-1) AND V>100000;
      AddColumn(V, “Volume“, 1);


      This code scans Volume of stocks to the previous day and brings out shares which have 10 times of volume of stocks traded on the current day to the previous day. No: of shares is more than 1,00,000 . You can try by changing the conditions.

      For Intraday Volume Breakout Exploration I will be looking for the solution.

      Happy Trading !!

      Delete
  6. Hi Aryan,

    Thank you so much for your help. You have given me something to play around in amibroker. Let me do some research now and see how it goes.

    Happy Trading !!

    Regards,
    Jaspreet

    ReplyDelete
  7. Hi Aryan ,

    Do you have any afl that can plot multiple time frame in a single sheet in amibroker ? I am looking for something like below -

    https://www.youtube.com/watch?v=Hp2BBCjaoRI

    Please let me know if you can help me on this.

    Happy trading and thanks in advance :)

    Regards,
    Jaspreet

    ReplyDelete
    Replies
    1. Hi Jaspreet,

      I know that this is very sought after AFL but it actually has been created by a closed group of Amibroker coding experts and it is most probably controlled through DLL. I hope someday it comes out in public domain then it can be surely shared. :-)

      For now its not possible for me to get this kind of AFL. I have an AFL which plots a super imposed candle of a bigger time frame on a shorter time frame. If you have not already seen it then here is the link to the page where I have posted it.

      http://tradecatcher.blogspot.in/2016/12/multiple-timeframe-candlestick-chart.html

      Happy Trading & Have a Nice Time.

      Aryan.

      Delete
  8. Thank you so much Aryan for the quick reply and pointing me to the multiple timeframe chart afl. I will go through this and see how can i fit this in my trading. Looks pretty simple :)

    Happy trading and keep rocking :)

    Regards,

    ReplyDelete
    Replies
    1. You are Welcome Jaspreet !!

      Happy Trading & Take Care

      Aryan.

      Delete
  9. Please disregard my previous comment. It would be a great help if you could help edit your AFL code to also include today's O H L and with it's text written. Thanks in advance.

    ReplyDelete
    Replies
    1. Just Add this code through formula editor and make an afl for Current Day High Low Open Levels

      Plot(TimeFrameGetPrice( "H", inDaily, 0 ),"DH",colorBrown,styleThick);
      PlotText("High",BarCount,LastValue(TimeFrameGetPrice( "H", inDaily, 0 ),True),colorBrown);
      Plot(TimeFrameGetPrice( "L", inDaily, 0 ),"DL",colorBrightGreen,styleThick);
      PlotText("Low",BarCount,LastValue(TimeFrameGetPrice( "L", inDaily, 0 ),True),colorBrightGreen);
      Plot(TimeFrameGetPrice( "O", inDaily, 0 ),"DO",colorAqua,styleLine);
      PlotText("Open",BarCount,LastValue(TimeFrameGetPrice( "O", inDaily, 0 ),True),colorAqua);

      Delete
  10. Hello.ITS UDAY.I want one small heikanashi trading strategy for auto robotrade afl.plz I can pay some small amount also.
    Startegy is
    Buy rule-present candle high is greater than previous candle close
    Buy exit- present candle low is less than previous candle low.
    Sell entry-peesent candle low is less than previous candle close.
    Sell exit-present candle high is greater than previous candle high.
    Time frame-15,30,1hr
    Ph-9882200635

    ReplyDelete
    Replies
    1. Hello Uday,

      Unfortunately I am not an Amibroker Coder myself so it will not be possible for me to write the AFL for you. You can Google search for AFL writing services , there are plenty of websites where coders are providing paid services for the same.

      Have you manually backtested this strategy of yours' as Heiken Ashi Candles show average values therefore signals generated on Heiken Ashi Candles will have prices different from the Current prevailing prices.

      Happy Trading.

      Delete
  11. Hi sir.. I need CPR , Daily pivot , Daily R1,S1, Weekly R1,S1 and Mothly pivot in same afl .. Do u have ?

    ReplyDelete
    Replies
    1. Hi Deena,

      I will try to publish this kind of AFL . I hope it will be soon.

      Delete

    2. _SECTION_BEGIN("CPR Exploration");

      PrevDay = 0; // Value should be 1 if your database is updated upto current day

      PrevLow = Ref(L,-PrevDay);
      PrevHigh = Ref(H,-PrevDay);
      PrevClose = Ref(C,-PrevDay);

      Pivot = (PrevLow+PrevHigh+PrevClose)/3;
      BC = (PrevLow+PrevHigh)/2;
      TC = (Pivot-BC) + Pivot;

      NRThreshold = 0.2;
      NarrowRangeCond = (abs(TC-BC)/PrevClose*100) < NRThreshold;
      NarrowRange = WriteIF(NarrowRangeCond,"YES","NO");

      NarrowRangeFGColor=IIf(NarrowRangeCond,colorWhite,colorBlack);
      NarrowRangeBKColor=IIf(NarrowRangeCond,colorBrightGreen,colorWhite);

      R1 = (2*Pivot) - PrevLow;
      R2 = (Pivot+PrevHigh) - PrevLow;
      R3 = R1 + (PrevHigh-PrevLow);
      R4 = R3 + (R2-R1);

      S1 = (2*Pivot) - PrevHigh;
      S2 = Pivot - (PrevHigh-PrevLow);
      S3 = S1 - (PrevHigh-PrevLow);
      S4 = S3 - (S1-S2);

      Filter = C>10;

      AddColumn(PrevClose, "Close", 1.2,colorBlack,colorLightGrey,width=100);
      AddColumn(PrevLow, "Low", 1.2,colorBlack,colorLightGrey,width=100);
      AddColumn(PrevHigh, "High", 1.2,colorBlack,colorLightGrey,width=100);
      AddColumn(Pivot, "Pivot", 1.2, colorBlack, colorLightOrange,100);
      AddColumn(BC, "BC", 1.2, colorBlack, colorAqua,100);
      AddColumn(TC, "TC", 1.2, colorBlack, colorPaleTurquoise,100);
      AddTextColumn(NarrowRange, "NarrowRange",format=1.2,NarrowRangeFGColor,NarrowRangeBKColor);
      AddColumn(R1,"R1",1.2,colorWhite,colorBlueGrey,100);
      AddColumn(R2,"R2",1.2,colorWhite,colorBlueGrey,100);
      AddColumn(R3,"R3",1.2,colorWhite,colorBlueGrey,100);
      AddColumn(R4,"R4",1.2,colorWhite,colorBlueGrey,100);

      AddColumn(S1,"S1",1.2,colorWhite,colorTeal,100);
      AddColumn(S2,"S2",1.2,colorWhite,colorTeal,100);
      AddColumn(S3,"S3",1.2,colorWhite,colorTeal,100);
      AddColumn(S4,"S4",1.2,colorWhite,colorTeal,100);


      _SECTION_END();

      Delete
    3. Hi Aravind,

      Really great of you to share the code for the afl which a blog reader asked for. I will publish it on my Blog with your name as the sharer.

      Happy Trading !!

      Delete
  12. Hi sir , i have found out the same..am looking for afl scanner which intimates me when stock price reaches pdh and pdl ..

    ReplyDelete
    Replies
    1. Hi Deena,

      Glad that you found the required AFL which you were looking for. The above mentioned scanner AFL I will try to share asap.

      Happy Trading !!

      Delete
  13. The below code is plot dots in afl, how to plot lines in afl. please help me to add this in High, Midpoint, Low.
    Hl2 = ( H + L ) / 2;
    zordershift = 2;
    Plot( Hl2, "", colorWhite, styleDots | styleNoLine | styleNoLabel, Null, Null , 0, zordershift );

    ReplyDelete

Required US Government Disclaimer & CTFC Rule 4.41

Futures trading contains substantial risk and is not suitable for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only consider risk capital that should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. CTFC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS SUCH AS LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN. All trades, patterns, charts, systems, etc., discussed in this website or advertisement are for illustrative purposes only and not construed as specific advisory recommendations. All ideas and materials presented herein are for information and educational purposes only. No system or trading methodology has ever been developed that can guarantee profits or prevent losses. The testimonials and examples used herein are exceptional results which do not apply to average people and are not intended to represent or guarantee that anyone will achieve the same or similar results. Trades placed on the reliance of Trend Methods systems are taken at your own risk for your own account. This is not an offer to buy or sell futures interests.