take profit setting for auto update of same pair trades?

 

I know one broker whose MT4 platform will automatically update the take profit for working orders for the same currency pair.

Is there a platform setting for this or is it a customization for that broker?

What is the MT4 setting variable, the value for the setting to enable this?

Or if this a setting that the broker sets, what is it called so I can inquire if they have this feature enabled?

Example: Say I have three long trades for the same pair, the first being a market order and the other two being pending orders with lower prices/take profits. And then the price goes down and triggers the second pending order, the platform then automatically updates the take profit of the first order to that of the second order's t/p.

thanks in advance!

Scott

 

This occurs only for US brokers because of the stupid FIFO rule forced on us last year. The earliest opened trade must close before later ones.

Thus on that broker, the broker changes the TP of the earlier ones to match the lowest long trade TP.

IBFX implemented the FIFO in their side so the actual trades are FIFO compliant but without affecting the mql4 model. You'll have to research other US brokers.

Brokers with no US presence are unaffected.

 
WHRoeder:

This occurs only for US brokers because of the stupid FIFO rule forced on us last year. The earliest opened trade must close before later ones.

Thus on that broker, the broker changes the TP of the earlier ones to match the lowest long trade TP.

IBFX implemented the FIFO in their side so the actual trades are FIFO compliant but without affecting the mql4 model. You'll have to research other US brokers.

Brokers with no US presence are unaffected.

Actually, for my strategy, I want this behavior. I want to find a non-US broker that has this and can switch this feature for an account. Know any or how I could find one?

Or I want to find an Expert Advisor that does this or create one. Know of any?

 
double DIR; // +/-1
start(){
    int oo.count=0
    for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol() ){              // and my pair.
        double TP=OrderTakeProfit();
        oo.count++;                                     // V Assumes no hedging. V
        if (oo.count == 1){ double minTP = TP;  DIR=Direction(OrderType()); }
        else                MinimizeDIR(maxTP, TP);
    }
    for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber()  == magic.number             // my magic number
    &&  OrderSymbol()       == Symbol() ){              // and my pair.
        TP=OrderTakeProfit();
        if ((TP-minTP)*DIR > Point){    // Buy: TP > min | Sell: TP < max
            if (!OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 
                             minTP, 0) ){   Alert( "OrderModify(ticket=", 
                                OrderTicket(), ") failed: ", GetLastError() );
            }
        }
    }
}
double  Direction(int op_xxx){  return( 1. - 2. * (op_xxx%2) );                }
void    MinimizeDIR(double &a, double b, double d=EMPTY_VALUE){
                                        a=MathMinDIR(a,b,d);        return;    }
void    MaximizeDIR(double &a, double b, double d=EMPTY_VALUE){
                                        a=MathMaxDIR(a,b,d);        return;    }
double  MathMinDIR(double a, double b, double d=EMPTY_VALUE){
    if (d == EMPTY_VALUE) d=DIR;
                        if(d>0) return(MathMin(a,b));   return(MathMax(a,b));  }
double  MathMaxDIR(double a, double b, double d=EMPTY_VALUE){
    if (d == EMPTY_VALUE)   d=DIR;
                        if(d>0) return(MathMax(a,b));   return(MathMin(a,b));  }
 
WHRoeder:


Awesome - thanks!

I see the note that it assumes no hedging. I will be hedging, so is there a tweak to make it work?

 
ibotscott:
I see the note that it assumes no hedging. I will be hedging, so is there a tweak to make it work?
Write the code to handle each direction separately.
 
WHRoeder:
Write the code to handle each direction separately.

Finally getting back to this...

1) I don't understand the directional logic, fundamentally what it is doing and why, and the details of it. Please comment/explain.

2) Then once I understand that, then I'll have context for understanding your comment to handle each direction separately when hedging.

Thanks in advance!