Finding hourly highs/lows using 1 min data

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #10241 quote
    merc1203
    Participant
    Average

    Is there a command that specifies the max/min price between 2 past data points, ie max price(bar[1],bar[60], and then max price(bar[61,bar[120]) etc?

    Many thanks in anticipation …

    #10256 quote
    merc1203
    Participant
    Average

    Does anyone know how to do this, or if it is possible?

    #10269 quote
    Nicolas
    Keymaster
    Master

    Do you want to know the highest price only between 2 values or within the range of these 2 boundaries?

    #10270 quote
    merc1203
    Participant
    Average

    Hi Nicolas,

    … within the range – I am trying to calculate 60min o,h,l,c data from 1 min data …

    #10275 quote
    Nicolas
    Keymaster
    Master

    ok, but not from round hour to another round hour if I understand well?

    #10277 quote
    merc1203
    Participant
    Average

    Hi Nicolas,

    I would like to calculate them from round hour to round hour – yes

    #10278 quote
    merc1203
    Participant
    Average

    This is what I wrote but – surprise, surprise- not working 🙁

    REM Calculate 60min H/L
    
    H0 = 999999
    H1 = 999999
    H2 = 999999
    H3 = 999999
    H4 = 999999
    H5 = 999999
    H6 = 999999
    H7 = 999999
    H8 = 999999
    H9 = 999999
    H10 = 999999
    H11 = 999999
    H12 = 999999
    H13 = 999999
    H14 = 999999
    H15 = 999999
    H16 = 999999
    H17 = 999999
    H18 = 999999
    H19 = 999999
    H20 = 999999
    H21 = 999999
    H22 = 999999
    H23 = 999999
    
    L0 = 0
    L1 = 0
    L2 = 0
    L3 = 0
    L4 = 0
    L5 = 0
    L6 = 0
    L7 = 0
    L8 = 0
    L9 = 0
    L10 = 0
    L11 = 0
    L12 = 0
    L13 = 0
    L14 = 0
    L15 = 0
    L16 = 0
    L17 = 0
    L18 = 0
    L19 = 0
    L20 = 0
    L21 = 0
    L22 = 0
    L23 = 0
    if (Time = 005959) then
    H0 = highest[60](high)
    L0 = lowest[60](low)
    endif
    
    if (Time = 015959) then
    H1 = highest[60](high)
    L1 = lowest[60](low)
    endif
    
    if (Time = 025959) then
    H2 = highest[60](high)
    L2 = lowest[60](low)
    endif
    
    if (Time = 035959) then
    H3 = highest[60](high)
    L3 = lowest[60](low)
    endif
    
    if (Time = 045959) then
    H4 = highest[60](high)
    L4 = lowest[60](low)
    endif
    
    if (Time = 055959) then
    H5 = highest[60](high)
    L5 = lowest[60](low)
    endif
    
    if (Time = 065959) then
    H6 = highest[60](high)
    L6 = lowest[60](low)
    endif
    
    if (Time = 075959) then
    H7 = highest[60](high)
    L7 = lowest[60](low)
    endif
    
    if (Time = 085959) then
    H8 = highest[60](high)
    L8 = lowest[60](low)
    endif
    
    if (Time = 095959) then
    H9 = highest[60](high)
    L9 = lowest[60](low)
    endif
    
    if (Time = 105959) then
    H10 = highest[60](high)
    L10 = lowest[60](low)
    endif
    
    if (Time = 115959) then
    H11 = highest[60](high)
    L11 = lowest[60](low)
    endif
    
    if (Time = 125959) then
    H12 = highest[60](high)
    L12 = lowest[60](low)
    endif
    
    if (Time = 135959) then
    H13 = highest[60](high)
    L13 = lowest[60](low)
    endif
    
    if (Time = 145959) then
    H14 = highest[60](high)
    L14 = lowest[60](low)
    endif
    
    if (Time = 155959) then
    H15 = highest[60](high)
    L15 = lowest[60](low)
    endif
    
    if (Time = 165959) then
    H16 = highest[60](high)
    L16 = lowest[60](low)
    endif
    
    if (Time = 175959) then
    H17 = highest[60](high)
    L17 = lowest[60](low)
    endif
    
    if (Time = 185959) then
    H18 = highest[60](high)
    L18 = lowest[60](low)
    endif
    
    if (Time = 195959) then
    H19 = highest[60](high)
    L19 = lowest[60](low)
    endif
    
    if (Time = 205959) then
    H20 = highest[60](high)
    L20 = lowest[60](low)
    endif
    
    if (Time = 215959) then
    H21 = highest[60](high)
    L21 = lowest[60](low)
    endif
    
    if (Time = 225959) then
    H22 = highest[60](high)
    L22 = lowest[60](low)
    endif
    
    if (Time = 235959) then
    H23 = highest[60](high)
    L23 = lowest[60](low)
    endif
    
    once BuyLine = 0
    
    if time = 010000 and (H0 < H21) then
    BuyLine = H0
    elsif time = 010000 and (H0 < H22) then
    BuyLine = H0
    elsif time = 010000 and (H0 < H23) then
    BuyLine = H0
    else
    BuyLine = BuyLine[1]
    endif
    if time = 020000 and (H1 < H22) then
    BuyLine = H1
    elsif time = 020000 and (H1 < H23) then
    BuyLine = H1
    elsif time = 020000 and (H1 < H0) then
    BuyLine = H1
    else
    BuyLine = BuyLine[1]
    endif
    #11831 quote
    stratus
    Participant
    Average

    Please try this with 1 Minute time Frame:

    REM Calculate 60min H/L
    Once H0 = 999999
    Once H1 = 999999
    Once H2 = 999999
    Once H3 = 999999
    Once H4 = 999999
    Once H5 = 999999
    Once H6 = 999999
    Once H7 = 999999
    Once H8 = 999999
    Once H9 = 999999
    Once H10 = 999999
    Once H11 = 999999
    Once H12 = 999999
    Once H13 = 999999
    Once H14 = 999999
    Once H15 = 999999
    Once H16 = 999999
    Once H17 = 999999
    Once H18 = 999999
    Once H19 = 999999
    Once H20 = 999999
    Once H21 = 999999
    Once H22 = 999999
    Once H23 = 999999
    
    Once L0 = 0
    Once L1 = 0
    Once L2 = 0
    Once L3 = 0
    Once L4 = 0
    Once L5 = 0
    Once L6 = 0
    Once L7 = 0
    Once L8 = 0
    Once L9 = 0
    Once L10 = 0
    Once L11 = 0
    Once L12 = 0
    Once L13 = 0
    Once L14 = 0
    Once L15 = 0
    Once L16 = 0
    Once L17 = 0
    Once L18 = 0
    Once L19 = 0
    Once L20 = 0
    Once L21 = 0
    Once L22 = 0
    Once L23 = 0
    
    if (Time = 005900) then
    H0 = highest[60](high)
    L0 = lowest[60](low)
    endif
    if (Time = 015900) then
    H1 = highest[60](high)
    L1 = lowest[60](low)
    endif
    if (Time = 025900) then
    H2 = highest[60](high)
    L2 = lowest[60](low)
    endif
    if (Time = 035900) then
    H3 = highest[60](high)
    L3 = lowest[60](low)
    endif
    if (Time = 045900) then
    H4 = highest[60](high)
    L4 = lowest[60](low)
    endif
    if (Time = 055900) then
    H5 = highest[60](high)
    L5 = lowest[60](low)
    endif
    if (Time = 065900) then
    H6 = highest[60](high)
    L6 = lowest[60](low)
    endif
    if (Time = 075900) then
    H7 = highest[60](high)
    L7 = lowest[60](low)
    endif
    if (Time = 085900) then
    H8 = highest[60](high)
    L8 = lowest[60](low)
    endif
    if (Time = 095900) then
    H9 = highest[60](high)
    L9 = lowest[60](low)
    endif
    
    if (Time = 105900) then
    H10 = highest[60](high)
    L10 = lowest[60](low)
    endif
    if (Time = 115900) then
    H11 = highest[60](high)
    L11 = lowest[60](low)
    endif
    if (Time = 125900) then
    H12 = highest[60](high)
    L12 = lowest[60](low)
    endif
    if (Time = 135900) then
    H13 = highest[60](high)
    L13 = lowest[60](low)
    endif
    if (Time = 145900) then
    H14 = highest[60](high)
    L14 = lowest[60](low)
    endif
    if (Time = 155900) then
    H15 = highest[60](high)
    L15 = lowest[60](low)
    endif
    if (Time = 165900) then
    H16 = highest[60](high)
    L16 = lowest[60](low)
    endif
    if (Time = 175900) then
    H17 = highest[60](high)
    L17 = lowest[60](low)
    endif
    if (Time = 185900) then
    H18 = highest[60](high)
    L18 = lowest[60](low)
    endif
    if (Time = 195900) then
    H19 = highest[60](high)
    L19 = lowest[60](low)
    endif
    if (Time = 205900) then
    H20 = highest[60](high)
    L20 = lowest[60](low)
    endif
    if (Time = 215900) then
    H21 = highest[60](high)
    L21 = lowest[60](low)
    endif
    if (Time = 225900) then
    H22 = highest[60](high)
    L22 = lowest[60](low)
    endif
    if (Time = 235900) then
    H23 = highest[60](high)
    L23 = lowest[60](low)
    once BuyLine = 0
    if time = 010000 and (H0 < H21) then
    BuyLine = H0
    elsif time = 010000 and (H0 < H22) then
    BuyLine = H0
    elsif time = 010000 and (H0 < H23) then
    BuyLine = H0
    else
    BuyLine = BuyLine[1]
    endif
    if time = 020000 and (H1 < H22) then
    BuyLine = H1
    elsif time = 020000 and (H1 < H23) then
    BuyLine = H1
    elsif time = 020000 and (H1 < H0) then
    BuyLine = H1
    else
    BuyLine = BuyLine[1]
    endif
    #11832 quote
    stratus
    Participant
    Average

    Sorry

    There is one missing endif at line #148

    Some variables ar not used in the code. You will have an error message for each variable not used

    #11849 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    I would do it this way:

    // Hourly highs/lows using 1 min data responding to a request on PRC
    //
    // (but could also work for other timeframes lower than 1h, as long as each hourly candle and each lower timeframe candle end simultaneously, otherwise the code would be more complicated than this one - Noobywan)
    
    if OpenHour<>OpenHour[1] then
    barinit=intradaybarindex
    endif
    
    Maxthishour=highest[intradaybarindex-barinit+1](high)
    Minthishour=lowest[intradaybarindex-barinit+1](low)
    
    return Maxthishour as "Maxthishour", Minthishour as "Minthishour"
    #11886 quote
    Nicolas
    Keymaster
    Master

    Hi, don’t know if it’s the right answer to this question, but here is a solution to find the highest and lowest price each new hour:

    //hourly high/low
    
    once ll = low[1]*1000
    
    if hour<>hour[1] then
     hh = 0
     ll = low[1]*1000
    endif
    
    hh = max(hh,high)
    ll = min(ll,low)
    
    RETURN hh, ll
    #11893 quote
    Dymjohn
    Participant
    Senior

    Sorry guys but what does <> mean?

    #11902 quote
    Nicolas
    Keymaster
    Master

    <> means “different” or “not equal”.

    #34699 quote
    Roman
    Participant
    Junior

    Hallo, Nicolas,

    how can I modify your code to find the highest and lowest price each 4 hours?

    #34721 quote
    Roman
    Participant
    Junior

    Hallo, Nicolas,

    I need highs and lows of the last 4 hours in 5 min chart. How must I modify the code to get the same timing as in 4H Chart, i.e. my segments have the same start und end time as in 4H chart – at 010000, 050000, 090000 and so on?

     

     ONCE HH=0
    ONCE LL=low[1]*1000
    ONCE i = 0
    ONCE hhigh = 0
    ONCE llow = low[1]*1000

    if hour<>hour[1] then

    if i = 4 then

    HH=hhigh
    LL=llow
    TBarIndex=barindex
    drawsegment(TBarindex,HH,barindex,hhigh)
    drawsegment(TBarindex,LL,barindex,llow)
    hhigh = 0
    llow = low[1]*1000
    i=0

    endif

    i=i+1

    endif

    hhigh = max(hhigh,high)
    llow = min(llow,low)

    return HH AS "NEWHIGH", LL AS "NEWLOW"

    Deutschland-30-Kassa-1EUR-Mini-.jpg Deutschland-30-Kassa-1EUR-Mini-.jpg
Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.

Finding hourly highs/lows using 1 min data


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
merc1203 @merc1203 Participant
Summary

This topic contains 15 replies,
has 6 voices, and was last updated by Roman
8 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/05/2016
Status: Active
Attachments: 2 files
Logo Logo
Loading...