High/Low/Close previous day with time

Viewing 15 posts - 16 through 30 (of 34 total)
  • Author
    Posts
  • #180358 quote
    JMat45
    Participant
    Senior

    Still having trouble with this unfortunately, Roberto. The code pinpoints the previous day’s High, Low and Close just fine, but not the Open. I have compared both versions of the code with

        CurH  = open
        CurL  = open
        CurO  = open
    

    in lines 18-20 as per your original and also

        CurH  = high
        CurL  = low
        CurO  = close

    but neither seems to work, as you can see from the screenshot (Germany 40 – today and yesterday). The code pegs the previous day’s Open at 15,546.3, but you can clearly see from the big red candle at 0800 yesterday it was more like 15,579. Is there an easier way to do this with arrays? Just thinking out loud…

    Thanks again for your help on this.

    #180461 quote
    robertogozzi
    Moderator
    Master

    It’s due to IG having set the closing of the Daily candle at 00:00 (Utc +1 +DST). Currently it’s at 01:00.

    At 00:00 the date and time is updated on the platform, but the broker reports the previous day till day change at 01:00.

    Replace

    IF OpenDay <> OpenDay[1] THEN

    by

    IF (OpenTime = 000000) OR ((OpenTime > 000000) AND (OpenTime[1] > OpenTime)) THEN
    JMat45 thanked this post
    #180482 quote
    JMat45
    Participant
    Senior

    Thanks for this, Roberto, but it’s made no difference on my end… It seems to be taking the Open of the first bar at 0000 (midnight) rather than at 0800…

    #180494 quote
    robertogozzi
    Moderator
    Master

    Use this line:

    IF (OpenTime = 080000) THEN
    #180524 quote
    JMat45
    Participant
    Senior

    Still no joy…

    #180531 quote
    robertogozzi
    Moderator
    Master

    Please post the code you are using and your conditions, as they may be quite different from the original code.

    #180533 quote
    JMat45
    Participant
    Senior

    Sure, I have doubled up on the code to give me the OHLC levels for two different sessions simultaneously:

    ONCE FromD = 080000
    dCond = (OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5)
    
    //////////////////////////////// Cash session 1 (8.00am-4.35pm)
    ONCE ToD1 = 163000
    ONCE CurO1 = open
    ONCE PrevO1 = open
    ONCE CurH1 = high
    ONCE PrevH1 = high
    ONCE CurL1 = low
    ONCE PrevL1 = low
    ONCE CurC1 = close
    ONCE PrevC1 = close
    
    tCond1 = OpenTime >= FromD AND OpenTime <= ToD1
    
    IF OpenTime = FromD THEN
    PrevO1 = CurO1
    PrevH1 = CurH1
    PrevL1 = CurL1
    PrevC1 = CurC1
    CurO1 = open
    CurH1 = open
    CurL1 = open
    // CurC1  = close
    ENDIF
    
    IF dCond AND tCond1 THEN
    IF CurL1 = CurO1 THEN
    CurH1 = high
    CurL1 = low
    ENDIF
    CurH1 = max(CurH1,high)
    CurL1 = min(CurL1,low)
    CurC1 = close
    ENDIF
    
    //////////////////////////////// Cash session 2 (8.00am-9.00pm)
    ONCE ToD2 = 205500
    ONCE CurO2 = open
    ONCE PrevO2 = open
    ONCE CurH2 = high
    ONCE PrevH2 = high
    ONCE CurL2 = low
    ONCE PrevL2 = low
    ONCE CurC2 = close
    ONCE PrevC2 = close
    
    tCond2 = OpenTime >= FromD AND OpenTime <= ToD2
    
    IF OpenTime = FromD THEN
    PrevO2 = CurO2
    PrevH2 = CurH2
    PrevL2 = CurL2
    PrevC2 = CurC2
    CurO2 = open
    CurH2 = open
    CurL2 = open
    // CurC2  = close
    ENDIF
    
    IF dCond AND tCond2 THEN
    IF CurL2 = CurO2 THEN
    CurH2 = high
    CurL2 = low
    ENDIF
    CurH2 = max(CurH2,high)
    CurL2 = min(CurL2,low)
    CurC2 = close
    ENDIF
    
    RETURN PrevO1 coloured(255,140,0) STYLE(line,3) AS "Previous day Open 4.35pm", PrevH1 coloured(0,0,255,255) STYLE(line,3) AS "Previous day High 4.35pm", PrevL1 coloured(0,0,255,255) STYLE(line,3) AS "Previous day Low 4.35pm", PrevC1 coloured(0,0,0) STYLE(line,3) AS "Previous day Close 4.35pm", PrevO2 coloured(255,180,0) STYLE(line,1) AS "Previous day Open 9.00pm", PrevH2 coloured(50,50,255,255) STYLE(line,1) AS "Previous day High 9.00pm", PrevL2 coloured(50,50,255,255) STYLE(line,1) AS "Previous day Low 9.00pm", PrevC2 coloured(50,50,50) STYLE(line,1) AS "Previous day Close 9.00pm"
    
    #180538 quote
    smp
    Participant
    Average

    Hi guys,

    Will you be so kind to make an indicator that shows:

    high (blue) / low (blue) / close (yellow) of the previous day

    with Monday showing the previous Friday

    with time setting (for example from 09.00 – 17.35 hours)

    for use in intraday charts

    Thank you in advance!

    SMP – Would this be of use.  I am waiting for this to be uploaded into the library.  It’s an EOD (End of day) Cash Market Pivots Indicator!

    #180541 quote
    robertogozzi
    Moderator
    Master

    I changed the colouring so that at the beginning od the evening session, the prior session is no longer visible (is this what you wanted?).

    As to time change, I can’t spot any glitch:

    ONCE FromD = 080000
    dCond = (OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5)
     
    //////////////////////////////// Cash session 1 (8.00am-4.35pm)
    ONCE ToD1 = 163000
    ONCE CurO1 = open
    ONCE PrevO1 = open
    ONCE CurH1 = high
    ONCE PrevH1 = high
    ONCE CurL1 = low
    ONCE PrevL1 = low
    ONCE CurC1 = close
    ONCE PrevC1 = close
     
    tCond1 = OpenTime >= FromD AND OpenTime <= ToD1
     
    IF OpenTime = FromD THEN
    t      = 255
    PrevO1 = CurO1
    PrevH1 = CurH1
    PrevL1 = CurL1
    PrevC1 = CurC1
    CurO1 = open
    CurH1 = open
    CurL1 = open
    // CurC1  = close
    ENDIF
     
    IF dCond AND tCond1 THEN
    IF CurL1 = CurO1 THEN
    CurH1 = high
    CurL1 = low
    ENDIF
    CurH1 = max(CurH1,high)
    CurL1 = min(CurL1,low)
    CurC1 = close
    ENDIF
     
    //////////////////////////////// Cash session 2 (8.00am-9.00pm)
    ONCE ToD2 = 205500
    ONCE CurO2 = open
    ONCE PrevO2 = open
    ONCE CurH2 = high
    ONCE PrevH2 = high
    ONCE CurL2 = low
    ONCE PrevL2 = low
    ONCE CurC2 = close
    ONCE PrevC2 = close
     
    tCond2 = OpenTime >= FromD AND OpenTime <= ToD2
     
    IF OpenTime = FromD THEN
    PrevO2 = CurO2
    PrevH2 = CurH2
    PrevL2 = CurL2
    PrevC2 = CurC2
    CurO2 = open
    CurH2 = open
    CurL2 = open
    // CurC2  = close
    ENDIF
     
    IF dCond AND tCond2 THEN
    IF CurL2 = CurO2 THEN
    CurH2 = high
    CurL2 = low
    ENDIF
    CurH2 = max(CurH2,high)
    CurL2 = min(CurL2,low)
    CurC2 = close
    ENDIF
    
    IF OpenTime >= ToD1 THEN
    t = 0
    ENDIF
    
    RETURN PrevO1 coloured(255,140,0,t) STYLE(line,3) AS "Previous day Open 4.35pm", PrevH1 coloured(0,0,255,t) STYLE(line,3) AS "Previous day High 4.35pm", PrevL1 coloured(0,0,255,t) STYLE(line,3) AS "Previous day Low 4.35pm", PrevC1 coloured(0,0,0,7) STYLE(line,3) AS "Previous day Close 4.35pm", PrevO2 coloured(255,180,0) STYLE(line,1) AS "Previous day Open 9.00pm", PrevH2 coloured(50,50,255,255) STYLE(line,1) AS "Previous day High 9.00pm", PrevL2 coloured(50,50,255,255) STYLE(line,1) AS "Previous day Low 9.00pm", PrevC2 coloured(50,50,50) STYLE(line,1) AS "Previous day Close 9.00pm"
    #180547 quote
    JMat45
    Participant
    Senior

    Thanks, Roberto. I hadn’t thought of that design element, but that’s actually very helpful. There are only two outstanding issues as far as I can see:

    1. The indicator now does not show the Previous day Close @ 1635 as per the attached screenshot.
    2. It appears that, in order for the code to use the correct bars for the end of the session, you have to use the time of the bar close one before the desired session end time (so in this case 163000 instead of 163500 and 205500 instead of 210000), which means the thicker lines stop one bar (in this case – on a 5-min timeframe – 5 mins) early. Any way of remedying this?

    Thanks again,

    JM

    #180562 quote
    robertogozzi
    Moderator
    Master

    My bad…I wrote 7 instead of t in line 77.

    PrevC1 coloured(0,0,0,7)  should read PrevC1 coloured(0,0,0,t).

    JMat45 thanked this post
    #204310 quote
    Tom.J
    Participant
    New

    Hello

     

    Thanks for this code.

    I understand how to adjust so it shows the high and low from all the day (midnight to midnight).

    But what I would like some help with is this: I would like the script to print the high and low from the previous day according to a specific timezone (NY-timezone, which my PRT are set to). Now I think it takes the high and low from the daily candle.

    Thanks for any help!

    #204319 quote
    smp
    Participant
    Average

    If you want to track and display end-of-day (EOD) pivots on cash markets, you CAN NOT do this using coding and measuring last-day high/low etc.  You cannot do this automatically because the real close is determined in the “settling period”, which, depending on the cash market you are trading, is between 5 minutes and 12 minutes.  During this period, a price is determined and set in this period.

    These are the accurate pivots and are used by institutions and professional traders.  Take it from a pro-trader; you are wasting time trying to automate using chart data.  Also, depending on the broker (Take IG as an example), they have a 24-hour market and “make” the market so a user can trade “out of hours”, so their candles at the close are not accurate.

    I have shared an EOD pivot indicator, which is correct and works on all cash markets.

    You are wasting your time automating pivots that are not correct.

    I hope this helps.

    Steve

    #204330 quote
    Tom.J
    Participant
    New

    Thanks for yout reply.

    I dont want to track eod data on cash markets. I am trading fx and want to track high and low of previos day (which I define as NY midnight to midnight). I see now the original question was in regards to cash markets, hence the confusion I think.

    #204561 quote
    robertogozzi
    Moderator
    Master

    Is this what you want?

    ONCE NYtime = 060000
    ONCE CurH   = high
    ONCE PrevH  = high
    ONCE CurL   = low
    ONCE PrevL  = low
    IF (OpenTime = NYtime) OR ((OpenTime > NYtime) AND (OpenTime[1] < NyTime)) THEN
       PrevH    = CurH
       PrevL    = CurL
       CurH     = high
       CurL     = low
    ENDIF
    CurH        = max(high,CurH)
    CurL        = min(low,CurL)
    RETURN PrevH coloured("Blue") AS "Previous DAY high",PrevL coloured("Red") AS "Previous DAY low"
    Tom.J thanked this post
Viewing 15 posts - 16 through 30 (of 34 total)
  • You must be logged in to reply to this topic.

High/Low/Close previous day with time


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Friend @friend Participant
Summary

This topic contains 33 replies,
has 8 voices, and was last updated by Tom.J
3 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/17/2020
Status: Active
Attachments: 6 files
Logo Logo
Loading...