close all orders with the same TakeProfit

Created at 01 Sep 2012, 02:04
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

close all orders with the same TakeProfit
01 Sep 2012, 02:04


hello

     I want to spend (with a single instance) several orders to buy or sell up to get a TakeProfit and close all orders with the same TakeProfit

      for example
      [Parameter ("Take Profit", DefaultValue = 10)] ..
     ("10", all accumulated orders)

 

 

excuse my bad English spoken

 

cordially

 

tradermatrix


@tradermatrix
Replies

admin
03 Sep 2012, 10:04

Hi

You want to set the same Take Profit and Stop Loss for all your positions? Is that correct?


@admin

tradermatrix
03 Sep 2012, 18:18

yes I want to cut with TakeProfit when, for example P & L = 10

 [Parameter("Take Profit", DefaultValue = 10)]

EXEMPLE RANGE ROBOT(or another robot)

ID Heure Symbole Volume Type Entrée T/P S/L Pips Swap Commissions EUR
195826 03/09/2012 14:39 EURUSD 10k Sell 1.25745     -0.3 0.00 -0.30 -0.24
195833 03/09/2012 14:42 EURUSD 10k Sell 1.25745     -0.3 0.00 -0.30 -0.24
195862 03/09/2012 15:15 EURUSD 10k Buy 1.25682     5.8 0.00 -0.30 4.61
195875 03/09/2012 15:21 EURUSD 10k Buy 1.25709     3.1 0.00 -0.30 2.47
195899 03/09/2012 15:51 EURUSD 10k Buy 1.25702     3.8 0.00 -0.30 3.02
195945 03/09/2012 16:28 EURUSD 10k Sell 1.25692     -5.6 0.00 -0.30 -4.45
195955 03/09/2012 16:36 EURUSD 20k Sell 1.25692     -5.6 0.00 -0.60 -8.91
195962 03/09/2012 16:41 EURUSD 10k Buy 1.25694     4.6 0.00 -0.30 3.66
195965 03/09/2012 16:44 EURUSD 20k Buy 1.25698     4.2 0.00 -0.60 6.68
195982 03/09/2012 16:49 EURUSD 10k Buy 1.25696     4.4 0.00 -0.30 3.50
196035 03/09/2012 17:21 EURUSD 10k Sell 1.25742     -0.6 0.00 -0.30 -0.48
 

        

 

I want that when P & L = 10, all positions are automatically sold

          cordialement                                                                                                               

  P & L non réalisé 5.72

 

 

 

TRADERMATRIX

 
                  ppppp      

 

lllll

                                                                                                                                                                                                                  

@tradermatrix

admin
05 Sep 2012, 15:46

Hello,

What you can do is the following: 

 

        protected override void OnTick()
        {
            foreach (var position in Account.Positions)
            {
                if (position.GrossProfit >= 10)
                {
                    Trade.Close(position);
                }
            }
        }



Let us know if that worked for you.

 


@admin

tradermatrix
06 Sep 2012, 14:57

bonjour

Unfortunately not, I want to automatically close all orders Buy and Sell when P & L = 10

the method closes the orders (profit = 10) one after the other

 

cordialement

 

TRADERMATRIX


@tradermatrix

admin
06 Sep 2012, 16:12

Hello,

The below code must be what you might need:

 

protected override void OnTick()
{         
    if( Account.Equity - Account.Balance > 10 )
    {
	foreach (var position in Account.Positions)
       	{
               	Trade.Close(position);
       	}
    }
}



Let us know if that worked for you!


@admin

tradermatrix
06 Sep 2012, 21:17

YES!Image feu d\'artifice

 

 thank you very much
 I can make beautiful robots

Image science fiction - science fiction extra terrestres surnaturel


 see you soon

 

 

 

TRADERMATRIX Image science fiction - science fiction extra terrestres surnaturel


@tradermatrix

leo8three
14 May 2014, 17:47

RE: Hello,

Hi 

do we need the declaration:

using cAlgo.API.Internals;

 

to make it works?

 

Thanks a lot

 

admin said:

The below code must be what you might need:

 

protected override void OnTick()
{         
    if( Account.Equity - Account.Balance > 10 )
    {
	foreach (var position in Account.Positions)
       	{
               	Trade.Close(position);
       	}
    }
}


 

Let us know if that worked for you!

 


@leo8three