Time as a cBot Input by optimization

Created at 08 Dec 2017, 09:34
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!
CI

cicondo

Joined 18.12.2012

Time as a cBot Input by optimization
08 Dec 2017, 09:34


Good Day @all

I'm using an integer for a specific time window within the bot have to accept new orders.
Let's say EntryTime = 1005 -> means 10:00

By running the optimization I use an increment by 5 which inreases the EntryTime parameter 1010... 1015 and so on.

My code make sure that only valif values are accepted but the when I'm rewriting the valid vauel to the parameter it will not 
work correctly.

e.g. it show a value like 1075 wich is not the rigt value I'm currently using within the pass interation of the optimization...
 

         protected override void OnStart()
        {

            ......

            Positions.Opened += new Action<PositionOpenedEventArgs>(Positions_Opened);

            _oldEntryTime = NormalizeTime(_oldEntryTime, EntryTime);
            _oldExitTime = NormalizeTime(_oldExitTime, ExitTime);

            EntryTime = _oldEntryTime;
            ExitTime = _oldExitTime;
        }

Maybe somebody has any idea what I should do or there is an example, demonstrating the same intention.

Cheers
Markus


@cicondo
Replies

ap11
08 Dec 2017, 14:35

RE:

Hi Markus,

You can use integer value for minutes in total. One day have 24 * 60 = 1440 minutes. This way:
0 = 0:00
1439 = 23:59

Example:

var timeInMinutes = 615;
var timeSpan = TimeSpan.FromMinutes(timeInMinutes);
var hours = timeSpan.Hours;
var minutes = timeSpan.Minutes;
Print("Time is {0}:{1}", hours, minutes); // Output: Time is 10:15

Kind Regards,
Andrey

cicondo said:

Good Day @all

I'm using an integer for a specific time window within the bot have to accept new orders.
Let's say EntryTime = 1005 -> means 10:00

By running the optimization I use an increment by 5 which inreases the EntryTime parameter 1010... 1015 and so on.

My code make sure that only valif values are accepted but the when I'm rewriting the valid vauel to the parameter it will not 
work correctly.

e.g. it show a value like 1075 wich is not the rigt value I'm currently using within the pass interation of the optimization...
 

         protected override void OnStart()
        {

            ......

            Positions.Opened += new Action<PositionOpenedEventArgs>(Positions_Opened);

            _oldEntryTime = NormalizeTime(_oldEntryTime, EntryTime);
            _oldExitTime = NormalizeTime(_oldExitTime, ExitTime);

            EntryTime = _oldEntryTime;
            ExitTime = _oldExitTime;
        }

Maybe somebody has any idea what I should do or there is an example, demonstrating the same intention.

Cheers
Markus

 


@ap11