Stop the robot one day of the week

Created at 07 Jun 2017, 21:35
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

tradermatrix

Joined 24.07.2012

Stop the robot one day of the week
07 Jun 2017, 21:35


I would like to stop or put the bot on standby for example on Thursday from 10 pm but after taking profit ...
A person more gifted than me could she provide me with a piece of code ..?
many thanks


@tradermatrix
Replies

Mikro
09 Jun 2017, 17:03

If this is intended to be yust that try.

OnTick()
{
   if(Server.Time.DayOfWeek == DayOfWeek.Thursday && Server.Time.Value.Hours >= 10 )
   {
        ... your Logic
   }
}

A more flexible Approach could be to define different 'States' using Switches.

public enum States
{
   Idle,
   Trading,
   Closing
}

private States _myState

OnStart()
{
   _myState=Idle;
}

OnTick
{
   switch (States)
   {
      case Idle:
          ...your Logic
         break;

      case Trading:
          ...your Logic
         break;

      case Closing:
          ...your Logic
         break;
   }
}

If one State has been completed, like on closing a Position you set _myState to the next State an only the Logic in this Switch Statement ist going to be executed.

 

cheers

Mirko


@Mikro

tradermatrix
09 Jun 2017, 17:40

Thank you MiKro for your code
I will study all this and try to adapt it.
cordially


@tradermatrix