set maximum...................

Created at 05 Nov 2013, 19:48
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!
RA

rawand

Joined 05.11.2013

set maximum...................
05 Nov 2013, 19:48


how can i set maximum trade volume that the robot is trading ?

and how can i stop the robot if 10 losing trades in a row are closed?


@rawand
Replies

rawand
06 Nov 2013, 15:41

can anyone code this, please?


@rawand

adaled
06 Nov 2013, 17:42

Maybe this helps for the first request: /forum/calgo-reference-samples/499

Check the forum there should be more code examples.

ten losing trades that the same robot opened? You can use the OnPositionClosed method increase a global variable if the position has a loss and decrease it otherwise. If that variable reaches 10 it means there were 10 consecutive losses. then call the method Stop();

        protected override void OnPositionClosed(Position position)
        {
            if (position.GrossProfit < position.Commissions)
                _loss++;
            else
                _loss--;

            if(_loss == 10)
                Stop();
        }

 


@adaled