Cancel previous trade profit when a new order is submitted.

 

I have this code:


#include <Trade\Trade.mqh>

CTrade trade;



double MACDValues1M[];

int MACD1M = iMACD(_Symbol, PERIOD_M1, 12, 26, 9, PRICE_CLOSE);

ArraySetAsSeries(MACDValues1M, true);

CopyBuffer(MACD1M, 0, 0, 3, MACDValues1M);



traderStartValue = 50;



if(MACDValues1M[1]<traderStartValue) {

        double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);

        trade.Sell(1, _Symbol, Bid, 0, Bid-250, NULL);

}

The problem is as follows:

If I send a sell (or buy, whatever) order at the price of 1000, the order is sent and a take profit of 9750 is determined.

But if a new sell (or buy, whatever) order occurs, the take profit of the previous order is canceled and both orders are reset when the new take profit is reached.

How do I get orders to be handled individually? I want to keep two orders with different take profits.

 
fernandoissler: I have this code: The problem is as follows: If I send a sell (or buy, whatever) order at the price of 1000, the order is sent and a take profit of 9750 is determined. But if a new sell (or buy, whatever) order occurs, the take profit of the previous order is canceled and both orders are reset when the new take profit is reached. How do I get orders to be handled individually? I want to keep two orders with different take profits.

That happens because you are most probably using a "netting" account, where only one "net" position is maintained per symbol.

If you want to manage multiple positions on the same symbol, you have to use a "hedging" account instead.