Trading Session

Created at 26 Mar 2014, 18:55
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!
OL

Old Account

Joined 14.10.2013

Trading Session
26 Mar 2014, 18:55


Hi

Is there a way to get the trading session without using the server time and looking at open and close time of the session. Since cAlgo already displays the session in the lower left corner.

Thanks


@Old Account
Replies

Spotware
27 Mar 2014, 09:21

No, cAlgo.API doesn't provide such functionality. You can add your idea to vote.spotware.com


@Spotware

AlexanderRC
27 Mar 2014, 19:45

RE:

MRSV said:

Hi

Is there a way to get the trading session without using the server time and looking at open and close time of the session. Since cAlgo already displays the session in the lower left corner.

Thanks

See this thread for ideas to vote for.


@AlexanderRC

sebo1999
18 Jun 2018, 16:17

MarketHours.Session

Dear sirs,

 

This new "MarketHours.Session" dose the trick?

Please I need an example of how to use it

 

Be


@sebo1999

sebo1999
18 Jun 2018, 16:18

Be = Best regards...


@sebo1999

PanagiotisCharalampous
18 Jun 2018, 16:28

Hi sebo1999,

Could you be more specific on what example do you need? You can get the trading sessions from the  Symbol.MarketHours.Sessions property.

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

sebo1999
18 Jun 2018, 18:15

MarketHours.Session example request

Hello Thank you for quick response

After one of the updates we have a new thing at the Internals section of the cAlgo

MarketHours.Session :

https://ctdn.com/api/reference/internals/markethours

My question is how to use that in a cBot. Example please

Best Regards


@sebo1999

PanagiotisCharalampous
19 Jun 2018, 10:05

Hi sebo1999,

See below an example on how to print the trading sessions of a symbol

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            foreach (var session in Symbol.MarketHours.Sessions)
            {
                Print("Session Starts: " + session.StartDay + " " + session.StartTime.ToString());
                Print("Session Ends: " + session.EndDay + " " + session.EndTime.ToString());
            }
        }

        protected override void OnTick()
        {
           
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
26 Oct 2018, 07:05

RE:

Panagiotis Charalampous said:

Hi sebo1999,

See below an example on how to print the trading sessions of a symbol

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            foreach (var session in Symbol.MarketHours.Sessions)
            {
                Print("Session Starts: " + session.StartDay + " " + session.StartTime.ToString());
                Print("Session Ends: " + session.EndDay + " " + session.EndTime.ToString());
            }
        }

        protected override void OnTick()
        {
           
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis

This is nice, but hou do I put trades in a correct time?


@alexander.n.fedorov

alexander.n.fedorov
26 Oct 2018, 08:06

Dear Panagiotis:

 

I was trying to run a robot on SPA35 index, which opens at 10 am.

I received a message that I couldnot because the maket to this symbol is closed

I could not find correct solution

 

Please, help

Regargs, Sasha


@alexander.n.fedorov

PanagiotisCharalampous
26 Oct 2018, 09:12

Hi Sasha,

Use IsOpened function.

Best Regards,

Panagiotis


@PanagiotisCharalampous

alexander.n.fedorov
26 Oct 2018, 11:26

Hi, Panagiotis. 
That is what i do, but means, I have to put the whole body of bot inside it

All right. Thank you

 

Regards, 

Sasha


@alexander.n.fedorov

PanagiotisCharalampous
26 Oct 2018, 11:28

Hi Sasha, 

You can just check this condition before executing an order.

Best Regards,

Panagiotis


@PanagiotisCharalampous