High Low Mid during trading hour

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #227899 quote
    Annchow8052014
    Participant
    New

    Hi All,

    Can anyone help me to find the highest, lowest point and middle point during my trading hour, since I find that DHigh or Dlow record the highest point or lowest point before the trading hour, and my trading hour is 091500 to 030000.

    Thanks in advance.

    #227917 quote
    JS
    Participant
    Senior

    Hi,

    From 091500 to 030000 is 17.75 hours or 71 x 15 minutes.

    When using a 15-minute timeframe:

    TimeFrame(15 minutes)

    If Time=030000 then

    xHighest=Highest[71](High)

    xLowest=Lowest[71](Low)

    EndIf

    xMiddle=(xHighest + xLowest)/2

    Return xHighest as “Highest”, xLowest as “Lowest”, xMiddle as “Middle”

    #228022 quote
    Annchow8052014
    Participant
    New
    Hi JS, Thank you for reply. Since I am using 1 minute time frame, and I want to have these high, low and middle during the trading hour, can you amend the code for me with thanks in advance.
    #228110 quote
    JS
    Participant
    Senior

    Hi Annchow,

    If you want the indicator to be “Live”, you will have to choose a certain look-back period…

    Try this… (period subject to change)

    DefParam DrawOnLastBarOnly=True
    
    //Period=100
    
    If Time<091500 and Time>030000 then
    xHighest=High
    xLowest=Low
    xMiddle=(High+Low)/2
    EndIf
    
    If Time>=091500 or Time<=030000 THEN
    
    xHighest=Highest[Period](High)
    DrawText("Highest=#xHighest#",-75,100,SansSerif,Bold,16)Coloured("Green") Anchor(Bottom)
    
    xLowest=Lowest[Period](Low)
    DrawText("Lowest=#xLowest#",-75,50,SansSerif,Bold,16)Coloured("Red") Anchor(Bottom)
    
    xMiddle=(xHighest+xLowest)/2
    DrawText("Middle=#xMiddle#",-75,75,SansSerif,Bold,16)Coloured("Blue") Anchor(Bottom)
    EndIf
    
    Return xHighest Coloured("Green") as "High",xLowest Coloured("Red") as "Low",xMiddle Coloured("Blue") as "Middle"

    #228126 quote
    Annchow8052014
    Participant
    New
    Hi JS, Thanks for your kindness and quick support . It is working good.
    #228128 quote
    Annchow8052014
    Participant
    New
    Hi JS, Further to my study, I find that the highest point have something wrong which record the highest point  before 9:15, can you help me to amend it with thanks.
    #228130 quote
    Annchow8052014
    Participant
    New
    Hi JS, Further to my study, I find that it record the highest point and lowest point during the 03:00 to 09:15 at the beginning of the trading hour.  Please help me to amend it with thanks.
    #228140 quote
    JS
    Participant
    Senior

    Hi Annchow,

    I’m a bit confused because you write in the beginning that you want to have the values during your trading hours (091500-030000)…

    So the indicator only shows the values during your trading hours and beyond that it is “just” the High and the Low of the price…

    #228142 quote
    Annchow8052014
    Participant
    New
    Hi JS, Sorry for any confusion.  Actually, I want to have the highest , lowest and middle point during my trading hour, however, your code provide me the highest or lowest point is not correct, it record the wrong highest point or lowest point especially during the beginning of the trading hour, please check with the pictures provided, please amend it for me with thanks.
    #228145 quote
    JS
    Participant
    Senior

    Hi Annchow,

    The code works with a certain look-back period, at the beginning (091500) this look-back period will also be used, (with data from before 0915000) and the output will be influenced by this…

    This is inevitable or you must leave the beginning blank until only date from after 0915000 is used…

    Hope it’s clear…

    #228159 quote
    Annchow8052014
    Participant
    New
    Hi JS, Noted with many thanks for your kindness support.
    JS thanked this post
    #228168 quote
    Annchow8052014
    Participant
    New
    Hi JS, Is it possible to design a loop to eliminate the look back ?
    #228170 quote
    JS
    Participant
    Senior

    Hi Annchow,

    In the PRT settings, try to set your trading times to your “trading hour” so that you only work with these times and automatically create the “Loop” you are talking about…

    #228179 quote
    Annchow8052014
    Participant
    New
    Hi JS, Further to my trying to reset the trading hour, it is quite difficult and not easy to setup after trial.  Thanks for your support .
    #228211 quote
    JC_Bywan
    Moderator
    Master
    Hi, Currently in prooder forum, that’s ok if you’re after a code snippet to include without a “return” line in a backtest/automatic strategy and are just visualising the code behaviour through an indicator, but in case you just wanted an indicator in the first place (please confirm) then I would move the topic to the probuilder forum. I hope I didn’t misunderstand the query, my understanding is you want customised highest and lowest (and their middle) starting at 9:15 in the morning, and going all the way to 3AM, and want to ignore what happens between 3 in the morning and 9:15 in the morning, with a code that works for 1 mn timeframe, is that correct? If yes, maybe you could try this:
    if opentime[1]<091500 and opentime>=091500 then
     hh=high
     ll=low
    endif
    if opentime>=091500 or opentime<030000 then
     hh=max(high,hh)
     ll=min(low,ll)
     mid=(ll+hh)/2
    else// in case you want to "park" hh and ll between 3AM and 9:15AM, you can choose any value you like, here high and low but can be anything else, like both on close if you prefer
     hh=high
     ll=low
     mid=(ll+hh)/2
    endif
    
    return ll as "My lowest", mid as "My middle", hh as "My highest"
    JS and Annchow8052014 thanked this post
Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.

High Low Mid during trading hour


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 15 replies,
has 3 voices, and was last updated by Annchow8052014
1 year, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/11/2024
Status: Active
Attachments: 3 files
Logo Logo
Loading...