# Trailing Stops and Trailing Profit

412

I need to use Trailing Stops and Trailing Profit.

My plan:

For Trailing Stop:

*After reaching a certain profit limit say 10 pips, the Stop Loss will move to 5 pips. Now if that trade retraces back to 5 pips then 'Two Third' of the trade will be Closed.

*Remaining 'One Third' will keep Running and 'Trailing Stop' wont be applied for it then.

For Trailing Profit:

*If that trade moves 5 pips more(i.e. 10+5=15 pips) then 'One Third' of that trade will be closed and remaining 'Two Third' will keep running.

*And then say after 10 pips more, (i.e. 15+10=25 pips) 'Half' of the remaining trade will be closed and the remaining 'Half' will keep running without any Take Profit limit.

But I am not Sure if it can be done for a 'Single' trade. That is why I was thinking a bit differently.

--->Three different trade will be opened of 'Same' of Lot at the 'Same' time.

--->Two of them will be closed if the price comes back to trailed stop loss level and remaining One will keep running for Trailing Stop part.

--->First trade will be closed at 'TP-1', Second trade will be closed at 'TP-2' and the last one will keep running for Trailing Profit part.

But how to Distinguish these trades? 'Order Ticket' can be used but there is no assurance that all these three trades will have consecutive Ticket serials as there will be other pair's trades too.

It is actually like for One trade the initial Stop Loss wont move.
5390

Are you a Programmer?

Are you learning how to Program?

Are you interested in learning how to Program your ideas?

If your answer is No to the above then Please try Searching the Code-Base for what you're looking for.

Arav007:

I need to use Trailing Stops and Trailing Profit.

My plan:

For Trailing Stop:

*After reaching a certain profit limit say 10 pips, the Stop Loss will move to 5 pips. Now if that trade retraces back to 5 pips then 'Two Third' of the trade will be Closed.

*Remaining 'One Third' will keep Running and 'Trailing Stop' wont be applied for it then.

For Trailing Profit:

*If that trade moves 5 pips more(i.e. 10+5=15 pips) then 'One Third' of that trade will be closed and remaining 'Two Third' will keep running.

*And then say after 10 pips more, (i.e. 15+10=25 pips) 'Half' of the remaining trade will be closed and the remaining 'Half' will keep running without any Take Profit limit.

But I am not Sure if it can be done for a 'Single' trade. That is why I was thinking a bit differently.

--->Three different trade will be opened of 'Same' of Lot at the 'Same' time.

--->Two of them will be closed if the price comes back to trailed stop loss level and remaining One will keep running for Trailing Stop part.

--->First trade will be closed at 'TP-1', Second trade will be closed at 'TP-2' and the last one will keep running for Trailing Profit part.

But how to Distinguish these trades? 'Order Ticket' can be used but there is no assurance that all these three trades will have consecutive Ticket serials as there will be other pair's trades too.

It is actually like for One trade the initial Stop Loss wont move.

412

ubzen:

Are you a Programmer?

Are you learning how to Program?

Are you interested in learning how to Program your ideas?

If your answer is No to the above then Please try Searching the Code-Base for what you're looking for.

I searched and then Posted this.

There are posts about 'Trailing Stops' but couldn't find 'Exactly' what I need. May be I have missed it there. So if you know the link please give me.

5390

Arav007: I searched and then Posted this. There are posts about 'Trailing Stops' but couldn't find 'Exactly' what I need. May be I have missed it there. So if you know the link please give me.
Sorry I cannot find one for you either. Please be patient, perhaps someone will come along and code it for you.
412

ubzen:
Sorry I cannot find one for you either. Please be patient, perhaps someone will come along and code it for you.

Actually I don't need the whole code. I just need to know which 'Logic' can be implemented here with which 'Function(s)'?

I have some Logic in my mind but need a way to 'Distinguish' the trades by 1,2,3.

6384

Arav007:

Actually I don't need the whole code. I just need to know which 'Logic' can be implemented here with which 'Function(s)'?

I have some Logic in my mind but need a way to 'Distinguish' the trades by 1,2,3.

then try to make it and show here your attempts when you don't succeed whatever you try....

implemented easiest way open 3 trades 'at new signal' then do your plan

412

I have thought something like this:

```for(cnt=3;cnt>0;cnt--)

{

if (cnt==1)

{

Disable Trailing Stop and Trailing Step

}

else

{

Enable Trailing Stop and Trailing Step

}

}

//Trailing Profit:

for(cnt=3;cnt>0;cnt--)

{

if (cnt==3)

{

Set take profit=TP1

}

if (cnt==2)

{

Set take profit= TP2

}

else

{

Disable Take Profit

}

}  ```

This is just schematic. There will be Flesh on this Skeletal if the 'Logic' works.

6384

Arav007:

I have thought something like this:

This is just schematic. There will be Flesh on this Skeletal if the 'Logic' works.

no you get signal to open sell or buy

now you have to make a logic you open 3 trades

with same stoploss

1 with takeprofit at your first level

1 with takeprofit at your second level

1 without a takeprofitlevel

412

deVries:

no you get signal to open sell or buy

now you have to make a logic you open 3 trades

with same stoploss

1 with takeprofit at your first level

1 with takeprofit at your second level

1 without a takeprofitlevel

So it's to be something like this?

```double dTakeProfitPrice_1=10;

double dTakeProfitPrice_2=20;

double dTakeProfitPrice_3=0;

{

{

{

}```

6384

Arav007:

So it's to be something like this?

stoploss you modify for two trades when the price has moved > 10 pips over orderopenprice

```double dTakeProfitPrice_1=10;

double dTakeProfitPrice_2=20;

double dTakeProfitPrice_3=0;
```{

{

{

{

}
{
....

{
....
}```
412

deVries:

stoploss you modify for two trades when the price has moved > 10 pips over orderopenprice

Sorry actually I have become confused a bit.

Here if the Total Opened Buy order is equal to '3' then the code will proceed to next part.

Then if the Total Opened Buy order's count is greater than '0' then it'll proceed to next.

Then if the Open Buy order count is equal to 3 then it'll open BuyOrder_1, if equal to '2' then it'll open BuyOrder_2 and then BuyOrder_3 is Opened Buy order count is equal to 1.

Am I right?