# Transfer the TP to the upper order

158

Hi

With this code

I want the expert to check the high purchase order. If the price of all the positions is positive, bring all the TPs to the high buy position.

But this must be done before the price reaches a high order position

But the code has a problem and it does not do that

```//+------------------------------------------------------------------+
{
//---
for(int i=0; i<OrdersTotal(); i++)
{
{
{
}
}
}
}
//+------------------------------------------------------------------+
void Trail()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{

if(OrderMagicNumber()==Magic3)
{
{

{
}
}
}
}
}```
25331

```for(int i=OrdersTotal()-1;i>=0;i--)
{

if(OrderMagicNumber()==Magic3)

{```
2. Your function call is only part of the if magic. Everything else below the bracket is always called.
158

William Roeder:
2. Your function call is only part of the if magic. Everything else below the bracket is always called.

Hi Dear William,

I changed the code this way but still could not get the desired result

```int start()
{
return(0);
}
//+------------------------------------------------------------------+
{
//---
for(int i=0; i<OrdersTotal(); i++)
{
{
{
{
{
}
}
}
}
}
}
//+------------------------------------------------------------------+```

25331

`if(OrderTakeProfit()>(Bid-MathPow(10,-Digits)*PriceOfHigherBuy))`
1. MathPow(10-Digits) is the same as _Point.
2. Point times a price is essentially zero, so you are comparing OTP to Bid which will always be true.
3. Don't you want to move the OTP if it is less than the current high?
4. You can't know the current high until you complete the loop.
158

William Roeder:
1. MathPow(10-Digits) is the same as _Point.
2. Point times a price is essentially zero, so you are comparing OTP to Bid which will always be true.
3. Don't you want to move the OTP if it is less than the current high?
4. You can't know the current high until you complete the loop.

Pay attention to the photo, we have 8 open positions. Before the price reaches it, the expert must find out in which of these positions all the positions (purchase) are in profit, then let him put all the TPs on the entry point of the same position.

`Don't you want to move the OTP if it is less than the current high?`

All profit margins must be equal at the entry point of one of the top positions, provided that the sum of all positions is in profit.

Thanks,

601

ghobar:

Hi

With this code

I want the expert to check the high purchase order. If the price of all the positions is positive, bring all the TPs to the high buy position.

But this must be done before the price reaches a high order position

But the code has a problem and it does not do that

```//+------------------------------------------------------------------+
{
//---
for(int i=0; i<OrdersTotal(); i++)
{
{
{
}
}
}
}```

Hello dear
This Function  returns the highest (not higher) price of buy orders(open price of 8th order). Is that what you want?

158

Salih Yasar:

Hello dear
This Function  returns the highest (not higher) price of buy orders(open price of 8th order). Is that what you want?

```Hello
I want, for example, when positions 3 or 4 or later are opened, the TP of all positions should be at the entry point of one of the top positions.
Transfer the TP of all positions to the entry point of one of the higher positions provided that our total profit is in profit```
601

ghobar:

Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)

158

Salih Yasar:

Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)

Hi dear Salih,
```Yes, I mean this
I want to put all the TPs in the price of one of the high open positions
Or position number 3 or 4 or 5 or 6 or 8
Provided that the sum of all positions is either overhead or the sum of all positions is in profit```
158

Salih Yasar:

Have you noticed that if you transfer TP to the last open price order, it means closing all active positions? (Although this is impossible because in BUY orders the TP must be higher than the current price)

What I want is perfectly stated in this photo

I hope you understand what I mean and help solve this problem

Thanks.

158

ghobar:

What I want is perfectly stated in this photo

I hope you understand what I mean and help solve this problem

Thanks.

Or

In this photo, we considered the buy position.