once a day

Created at 26 May 2015, 13: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!
TR

tranel

Joined 26.05.2015

once a day
26 May 2015, 13:55


Hi everyone!

I'm new here and I'm trying to write an algoritm that check some conditions once a day at a determinate hour.
Can somebody help me?

Thank you!
 


@tranel
Replies

deklin
26 May 2015, 14:08

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleSmartBotRobot : Robot
    {
        bool doneToday;

        protected override void OnStart()
        {
            doneToday = false;
        }
        protected override void OnTick()
        {
           var currentHour = int.Parse(Server.Time.ToString("%H"));
           if (currentHour >= 8 && doneToday == false) {
              doneToday = true;
              Print("This is done once per day at 8:00 am UTC or as close after that time as possible.");
           }
           else if (currentHour <= 1) {
              doneToday = true;
           }
        }
    }
}

 


@deklin

deklin
26 May 2015, 14:10

RE:

Sorry, I made a typo above... It should be: 

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleSmartBotRobot : Robot
    {
        bool doneToday;

        protected override void OnStart()
        {
            doneToday = false;
        }
        protected override void OnTick()
        {
           var currentHour = int.Parse(Server.Time.ToString("%H"));
           if (currentHour >= 8 && doneToday == false) {
              doneToday = true;
              Print("This is done once per day at 8:00 am UTC or as close after that time as possible.");
           }
           else if (currentHour <= 1) {
              doneToday = false;
           }
        }
    }
}

 


@deklin

tranel
26 May 2015, 17:24

Thank you very much.

This code can be use as well with the onBar metod isn't it?


@tranel