Advance take profit

Created at 16 Jul 2015, 18:27
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!
SH

Shawn_Mapilot

Joined 30.04.2015

Advance take profit
16 Jul 2015, 18:27


Is there a function that will allow me to close a portion of my trade after it reaches a certain amount of pips, like if I am trading a 0.10 lot and it hits my target but I only want to close 0.05 of the position then add a trailing stop to the remaining position. 


@Shawn_Mapilot
Replies

Makagon
16 Jul 2015, 23:34

Hi, if you have position 0.10 lot (for eurusd it's 10000) and want to close half of that, you can use this:

in section OnStart you add:

 Positions.Closed += PositionsOnClosed;

 

in section OnTick you add:

if .... something

and you want to close half of you position use this:

var position = Positions.Find("youLabelPosition");

        if (position != null)

            ClosePosition(position,5000);

 

in function

private void PositionsOnClosed(PositionClosedEventArgs args)

    {

      var position = Positions.Find("youLabelPosition");

        if (position != null)

     ModifyPosition(position, stopLoss, position.TakeProfit);

    }


@Makagon

Makagon
16 Jul 2015, 23:35

RE:

Makagon said:

Hi, if you have position 0.10 lot (for eurusd it's 10000) and want to close half of that, you can use this:

in section OnStart you add:

 Positions.Closed += PositionsOnClosed;

 

in section OnTick you add:

if .... something

and you want to close half of you position use this:

var position = Positions.Find("youLabelPosition");

        if (position != null)

            ClosePosition(position,5000);

 

in function

private void PositionsOnClosed(PositionClosedEventArgs args)

    {

      var position = Positions.Find("youLabelPosition");

        if (position != null)

     ModifyPosition(position, stopLoss, position.TakeProfit);

    }

ModifyPosition(position, stopLoss, NewTakeProfit);


@Makagon

Makagon
16 Jul 2015, 23:53

RE: RE:

Makagon said:

Makagon said:

Hi, if you have position 0.10 lot (for eurusd it's 10000) and want to close half of that, you can use this:

in section OnStart you add:

 Positions.Closed += PositionsOnClosed;

 

in section OnTick you add:

if .... something

and you want to close half of you position use this:

var position = Positions.Find("youLabelPosition");

        if (position != null)

            ClosePosition(position,5000);

 

in function

private void PositionsOnClosed(PositionClosedEventArgs args)

    {

      var position = Positions.Find("youLabelPosition");

        if (position != null)

     ModifyPosition(position, stopLoss, position.TakeProfit);

    }

ModifyPosition(position, stopLoss, NewTakeProfit);

OMG

ModifyPosition(position, NewStopLoss, NewTakeProfit);


@Makagon

Shawn_Mapilot
17 Jul 2015, 07:19

thank you 


@Shawn_Mapilot