security control

Created at 29 May 2013, 14:39
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!
DA

damon153058

Joined 13.04.2013

security control
29 May 2013, 14:39


security control

Requirements:

  1. $ -20 Unrealized p & l
  2. position all close
  3. stop all robots

Intentioned people can help me edit this program

Can someone please help me with the code?

Thanks


@damon153058
Replies

cAlgo_Fanatic
29 May 2013, 15:46

Hello,

You cannot stop all robots from one robot but only the one robot itself that contains the code which stops it.

The code would be such as this:

        protected override void OnTick()
        {
            if(NotEnoughEquity()) return;
            //...
               
        }

        private bool NotEnoughEquity()
        {
            
            if (Account.Balance - Account.Equity <= 20)
            {                
                foreach (Position openedPosition in Account.Positions)
                    Trade.Close(openedPosition);
                
                Stop();
                return true;
            }
            return false;
        }




@cAlgo_Fanatic

damon153058
29 May 2013, 19:46

RE:

You can close the program?


@damon153058

cAlgo_Fanatic
30 May 2013, 09:29

This line will stop the robot:

 Stop();

 

Please note there was a correction in the above code snippet. It should be:

if (Account.Balance - Account.Equity <= 20)

not 

if (Account.Equity <= 20)

 


@cAlgo_Fanatic

damon153058
06 Jun 2013, 18:05

RE:

security control

Requirements:

  1. $ -20 Unrealized p & l
  2. stop all robots

Intentioned people can help me edit this program

Can someone please help me with the code?

Thanks


@damon153058

adaled
07 Jun 2013, 10:00

Which program???

The first part was provided already. 
The second cannot be done...


@adaled

algoforce
26 Jul 2013, 10:39

 if (Account.Balance - Account.Equity <= 20) // can we bee more accurate and use the actual minimum volume margin requirement ( volume)



@algoforce

kricka
26 Jul 2013, 12:10

Hi damon153058,

to stop other robots running from another robot is not possible within the cAlgo platform. There is a 3th-party software that can handle this. Robotlink by Scyware. Google it and you will get more info on it.

The other question you have is more towards risk & money management of your trading account. There is many different way to handle this depending on how your basic robot is coded. The best way to learn is to study the cAlgo API reference and read and test your coding with the many samples provided. A lot of very good samples brings up the subject of money management and how to protect your self against drawdowns.

 

 


@kricka

Nego
26 Jul 2013, 16:16

RE:
kricka said:

Hi damon153058,

to stop other robots running from another robot is not possible within the cAlgo platform. There is a 3th-party software that can handle this. Robotlink by Scyware. Google it and you will get more info on it.

The other question you have is more towards risk & money management of your trading account. There is many different way to handle this depending on how your basic robot is coded. The best way to learn is to study the cAlgo API reference and read and test your coding with the many samples provided. A lot of very good samples brings up the subject of money management and how to protect your self against drawdowns.

 

 

Well, there is a way to stop all robots, as long as all robots constantly check for some sort of signal. For example, if you use a global variable as a flag that one robot sets true (such as glStopAllRobots = true). Now all Robots check OnTick or OnBar if this flag a) exists and b) is set to true. If this is so, stop the robot. 

If this doesnt work, you can always drop a note in a file that all robots read. 

All this only works when you have access to the robots code, of course....


@Nego

kricka
28 Jul 2013, 05:59

Hi Nego,

you are saying that it is possible to stop other robots from a main robot when it stops. How do you exactly write such a code in the main robot and in the other robot/s you would like to stop at the same time?

According to the Spotware team it is not possible to accomplish this.

Thanks if you can help me with this.


@kricka