Download MetaTrader 5

Does Trailing Profit exists?

To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
Gerardo Bustos
746
Gerardo Bustos 2015.05.08 00:17 

Hello forum, good day.

Is there a way to move the Take Profit just like a trailing stop would move the Stop Loss? I would like to move both values, lets say 30 pips for Stop Loss and Take Profit.


Best regards and thank you in advance,

Gerardo 

Aleksei Beliakov
24334
Aleksei Beliakov 2015.05.08 16:34  
sure thing, it's almost the same
Anderson Hupp
5944
Anderson Hupp 2015.05.08 18:45  
Gerardo Bustos:

Hello forum, good day.

Is there a way to move the Take Profit just like a trailing stop would move the Stop Loss? I would like to move both values, lets say 30 pips for Stop Loss and Take Profit.


Best regards and thank you in advance,

Gerardo 

I just don't see the point of moving the take profit. It would never be reach!

The stop loss on the other hand does make sense. 

Gerardo Bustos
746
Gerardo Bustos 2015.05.08 19:21  
Anderson Hupp:

I just don't see the point of moving the take profit. It would never be reach!

The stop loss on the other hand does make sense. 

The idea of this would be just in case the price goes higher/lower than the established Take Profit level. But I guess setting a really high Take Profit would do it, and then just moving the Stop Loss up/down to lock the profit.

 

Best regards and thank you,

Gerardo 

Alain Verleyen
Moderator
30752
Alain Verleyen 2015.05.08 20:40  
Anderson Hupp:

I just don't see the point of moving the take profit. It would never be reach!


You can move your takeprofit according to the market volatility. It's not necessarily always moved in the same direction.
Anderson Hupp
5944
Anderson Hupp 2015.05.08 22:43  
Alain Verleyen:
You can move your takeprofit according to the market volatility. It's not necessarily always moved in the same direction.

You're right Alain, that could be really useful!

Thank you! 

Gerardo Bustos
746
Gerardo Bustos 2015.05.08 23:34  
Alain Verleyen:
You can move your takeprofit according to the market volatility. It's not necessarily always moved in the same direction.

Hello Alain.

What would be the best or most recommended way to count orders in this case?

 

A:

for ( int i = total - 1; i >= 0; i-- )
  {
    ...
  }


or

 

B:

for ( int i = 0; i < total; i++ )
  {
    ...
  }

 

Best regards and thank you in advance,

Gerardo 

Alexander Puzanov
29612
Alexander Puzanov 2015.05.09 04:29  

C

int i = total;
while(i-- > 0) { ... }

 Actually it does not matter

Gerardo Bustos
746
Gerardo Bustos 2015.05.09 07:46  
Alexander Puzanov:

C

 Actually it does not matter

Thanks everyone for your reply! I need a bit of help though with my code.

I'm trying to move the Stop Loss with the following function, but instead of giving a better result than what my EA already gives, it is worst:

 

void Trail( int trailing_stop )
  {
    int  total = OrdersTotal();
    bool result;

    RefreshRates();

    if ( total > 0 )
      {
        for ( int cnt = 0; cnt < total; cnt++ )
          {
            if ( !OrderSelect( cnt, SELECT_BY_POS, MODE_TRADES ) ) continue;
            if ( OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber ) continue;

            if ( OrderType() == OP_BUY )
              {
                if ( ( Bid - OrderOpenPrice() > trailing_stop * Point ) && ( OrderStopLoss() < Bid - trailing_stop * Point ) )
                  {
                    double New_SL = Bid - trailing_stop * Point;
                    result        = OrderModify( OrderTicket(), OrderOpenPrice(), New_SL, OrderTakeProfit(), 0, clrBlue);

                    if ( result )
                      {
                        Print( "Trailing Stop for: ", OrderSymbol(), ". Stop Loss: ", New_SL, ". Bid: ", Bid );
                        return;
                      }
                  }
              }

            if ( OrderType() == OP_SELL )
              {
                if ( ( OrderOpenPrice() - Ask > trailing_stop * Point ) && ( OrderStopLoss() > Ask + trailing_stop * Point || OrderStopLoss() == 0 ) )
                  {
                    double New_SL = Ask + trailing_stop * Point;
                    result        = OrderModify( OrderTicket(), OrderOpenPrice(), New_SL, OrderTakeProfit(), 0, clrRed);

                    if ( result )
                      {
                        Print( "Trailing Stop for: ", OrderSymbol(), ". Stop Loss: ", New_SL, ". Ask: ", Ask );
                        return;
                      }
                  }
              }
          }
      }
  } 

 

I'm invoking the previous code inside the OnTick() function at the very top. I have a Stop Loss of 30, the Take Profit is 200 and the Trailing Stop is 50. It seems to me that the Stop Loss is not moving correctly and it is not locking the profit/reducing loss. Once I can make this work correclty, I would like to apply it to move the Take Profit depending on the volatility.


Your help will be much appreciated. 

 

Best regards and thank you in advance,

Gerardo 

To add comments, please log in or register