Jump to content
Medved Trader Forums

Detecting End of Session in Paintbar Logic when using using Range Bars


Doug Hayman

Recommended Posts

I'm looking for the purposes of back-testing, to close an open position if the current timestamp >= the End of Session.  However, I'm using Range Bars, where its timestamp completes at close of bar, and no bars are started, if not completed, prior to end of session.

Hence, the logic

Timestamp >= session.SessionEnd

doesn't achieve the desired results.

Can you offer any solutions here?

Thanks in advance.


 

 

Edited by Doug Hayman
Link to comment
Share on other sites

Well yes - with range candle, the timestamp of the last session candle is arbitrarily far away from the session end time. That's the nature of the range candles.

For the very last candle you can take the current UTC time - DateTime.UtcNow - and compare it to the SessionEnd. But that won't help you with past candles.

What you can do with those is check if the start of the range candle is past the end of the session, then do the calculation on the previous candle, as that would be the last session candle.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...