Elapsed time since market opening

Created at 12 Oct 2022, 08:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NC

ncel01

Joined 19.03.2020

Elapsed time since market opening
12 Oct 2022, 08:28


Hello,

How can I get/measure the elapsed time since market open time?

This is intended to better manage any gaps/volatility during this period.

Thank you.


@ncel01
Replies

ncel01
17 Oct 2022, 14:02

RE:

ncel01 said:

Hello,

How can I get/measure the elapsed time since market open time?

This is intended to better manage any gaps/volatility during this period.

Thank you.

Hello,

Is there any update on this?

Thank you.


@ncel01

xabbu
17 Oct 2022, 14:26 ( Updated at: 17 Oct 2022, 14:58 )

Hey ncel01,

You can try an onTimer with

Symbol.MarketHours.TimeTillClose() <= _afterSessionOpen

and before define

afterSessionOpen = "22:" + Convert.ToString(minutesAfter) + ":00";                    
TimeSpan.TryParse(afterSessionOpen, CultureInfo.InvariantCulture, out _afterSessionOpen);

So with that logic my trades are only executed if the time to market close is smaller 22 hours and x minutes, which means I don't trade between 23 pm and 1 am (my time) broker dependend - but you got the idea.

xabbu

 


@xabbu

ncel01
17 Oct 2022, 22:50

RE:

xabbu said:

Hey ncel01,

You can try an onTimer with

Symbol.MarketHours.TimeTillClose() <= _afterSessionOpen

and before define

afterSessionOpen = "22:" + Convert.ToString(minutesAfter) + ":00";                    
TimeSpan.TryParse(afterSessionOpen, CultureInfo.InvariantCulture, out _afterSessionOpen);

So with that logic my trades are only executed if the time to market close is smaller 22 hours and x minutes, which means I don't trade between 23 pm and 1 am (my time) broker dependend - but you got the idea.

xabbu

 

Hi xabbu,

Thanks for your reply.

I thought of implementing something similar or even defining a time period based on the current hours only.

However, I am more into trading indices and the working hours is not as "standard" as for FX and more "broker dependent". Also, there are some exceptions to this during the year, for which the time schedule is different.

In fact, and to make things easier, I was expecting a method similar to MarketHours.TimeTillClose()  (i.e. MarketHours.TimeAfterOpen()) to be available.

This way, it was possible to automate (based on the hours defined by the broker) a time interval that covers both market close and opening.

I am afraid that, without this method available, it won't be possible to get to an 100% accurate solution.

Sometimes I notice that similar methods/properties are not available, although these are very basic/intuitive..

Some other example: Account.Asset.Name

This is not available for a symbol. However, the currency is a basic/important attribute not only for an account but also of any instrument.. moreover, this can be needed for currency conversion and risk management purposes, which is for sure not a detail when trading. Although I found a solution for this, once again, it was not the most effective one.

Last but not least, thanks for your help. I really appreciate it!

 

ncel01


@ncel01