How to force Take Profit when take profit is not executed by broker - page 3

 
rrocchi:



press F8 for chart properties, Show tab then select "Show ask price line". 



Yes, I did it, please take  a look at the attached image

Files:
MT51.png  57 kb
 
adrianoferranti:

Correct. That is the new red price line (ASK price) showing almost behind the BID price.


This way you can monitor the trade: a SELL position will only Take Profit when that red line reaches your TP level. (and not the BID line price)

Create a new SELL position, set TP, observe the red ASK line until it reaches the TP, and you can see what is happening and/or preventing it from closing. Probably your broker is moving it very fast away from the BID line at some moments.

Now you can see it, and check it.


Post your reply here after the operation

Basic Principles - Trading Operations - MetaTrader 5
Basic Principles - Trading Operations - MetaTrader 5
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 

dear guys,

use this sample code on MT4 for closing in gap price for both SL & TP

  

extern int    Retries             = 20;     // Max Retries For Close Order
extern int    PauseBetweenRetries = 100;    // Pause Between Retries(Millisecond)

for (int c = OrdersTotal() - 1; c >= 0; c--)
{
    if (OrderSelect(c, SELECT_BY_TICKET, MODE_TRADES) && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
    {
        if (OrderType() == OP_BUY && ((OrderStopLoss() != 0.0 && Bid <= OrderStopLoss()) || (OrderTakeProfit() != 0.0 && Bid >= OrderTakeProfit())))
        {
            bool gapclose = false;
            gapclose = OrderClose(OrderTicket(), OrderLots(), Bid, OpenSlippage, clrYellow);
            if (!gapclose)
                for (int i = 1; i < Retries; i++)
                {
                    Print(" error on Close Buy Order in Gap, Error #", GetLastError(), " , Try to Close in Gap again, Try #", i);
                    RefreshRates();
                    if (gapclose)
                        break;
                    Sleep(PauseBetweenRetries);
                }
        }
        if (OrderType() == OP_SELL && ((OrderStopLoss() != 0.0 && Ask >= OrderStopLoss()) || (OrderTakeProfit() != 0.0 && Ask <= OrderTakeProfit())))
        {
            bool gapclose = false;
            gapclose = OrderClose(OrderTicket(), OrderLots(), Ask, OpenSlippage, clrYellow);
            if (!gapclose)
                for (int i = 1; i < Retries; i++)
                {
                    Print(" error on Close Sell Order in Gap, Error #", GetLastError(), " , Try to Close in Gap again, Try #", i);
                    RefreshRates();
                    if (gapclose)
                        break;
                    Sleep(PauseBetweenRetries);
                }
        }
        ResetLastError();
    }
}
 
rrocchi:

Correct. That is the new red price line (ASK price) showing almost behind the BID price.


This way you can monitor the trade: a SELL position will only Take Profit when that red line reaches your TP level. (and not the BID line price)

Create a new SELL position, set TP, observe the red ASK line until it reaches the TP, and you can see what is happening and/or preventing it from closing. Probably your broker is moving it very fast away from the BID line at some moments.

Now you can see it, and check it.


Post your reply here after the operation

Thanks for reply! I believe that I've found whats is happening. In order to debug the problem I have programatically invoked the positionClose method in case of the condition for triggering the TP or SL has been reached and received the message: "UNSUPPORTED FILLING MODE". I follow the instructions found here:   https://www.mql5.com/pt/forum/189682   and the position has been closed sucessfully, I suppose the trick were that my broker just accept ORDER_FILLING_RETURN in the filling mode field and this option was not used in the closePosition method. 

Not sure if it is the correct and unique solution for this issue but it's working :)

MT5 (UNSUPPORTED FILLING MODE)
MT5 (UNSUPPORTED FILLING MODE)
  • 2017.04.09
  • www.mql5.com
For personnel who are having problems filling out order in MT5 (UNSUPPORTED FILLING MODE) I was able to solve with the following changes within the...
Reason: