Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to reference the two previous sessions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to reference the two previous sessions

    ​I am thinking of designing an indicator that draws horizontal rays from some price levels that interest me.

    I split the trading day into two sessions: RTH and RTH.

    The RTH session is from 9:30 AM to 4:15 PM. The ETH session from 4:15 PM of the current trading day to 9:30 AM of the following trading day.

    What I would like to accomplish is to reference within OnBarUpdate() the levels of the last ETH session and the previous RTH session.

    In other words, I would like to get, in the current RTH session, the levels of the two most recent closed sessions ETH [0] and RTH [1].

    I guess I could try hacking around TimeHours. Any help will be welcome!

    #2
    Hello Gianpiero,

    Thank you for your note.

    You could use a time filter to separate your indicator's conditions between 9:30 AM-4:15 PM and 4:15 PM-9:30 AM. Then, you could potentially save the desired values to a variable for whichever levels you would like to access in the next session. We have a strategy sample that uses a time filter to limit trading hours; this could serve as an example of how to add time filters into your script:


    You could also consider using separate tags for the rays that are drawn and/or storing them in a Ray object so you can access values such as the StartAnchor and EndAnchor for the ray later on:


    Using separate tags could help so you could distinguish which ones were drawn during ETH and which were drawn during RTH. You may also access information via the DrawObjects collection based on the tag and type of an object like the examples on this page:


    These are just some general ideas to assist you; if you have more specific questions, please don't hesitate to reach out and we'd be glad to assist you further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    368 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    571 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X