Download MetaTrader 5
To add comments, please log in or register
Track all payments in your profile. It is easy!
Fringe
6
Fringe 2012.09.03 20:27 

Hi,

Can someone write for me short simple code which close position.

I used that code to open position but I can not close it.

            request.action = TRADE_ACTION_DEAL;
            request.symbol = _Symbol;
            request.volume = Lot;
            request.price = Bid;
            request.sl = Loss;
            request.tp = Profit;
            request.deviation = SP;
            request.type = PositionDirection;
            request.type_filling = ORDER_FILLING_FOK;
            OrderSend(request, result);

I expect something simple too.

Thanks for help. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types - Documentation on MQL5
Jin
1539
Jin 2012.09.03 23:50  
Fringe:

Hi,

Can someone write for me short simple code which close position.

I used that code to open position but I can not close it.

            request.action = TRADE_ACTION_DEAL;
            request.symbol = _Symbol;
            request.volume = Lot;
            request.price = Bid;
            request.sl = Loss;
            request.tp = Profit;
            request.deviation = SP;
            request.type = PositionDirection;
            request.type_filling = ORDER_FILLING_FOK;
            OrderSend(request, result);

I expect something simple too.

Thanks for help. 

You should try to use the stardand library, in particular, CTrade (#include <Trade\Trade.mqh>).

It simplify a lot stuffs like that. If you don't want to you it for some reason, look it anyway to find examples on how to use this kind of function corretly.

regards.

Dua Yong Rew
5131
Dua Yong Rew 2012.09.04 05:23  

Fringe 

Hi,

Can someone write for me short simple code which close position.

I used that code to open position but I can not close it.

            request.action = TRADE_ACTION_DEAL;
            request.symbol = _Symbol;
            request.volume = Lot;
            request.price = Bid;
            request.sl = Loss;
            request.tp = Profit;
            request.deviation = SP;
            request.type = PositionDirection;
            request.type_filling = ORDER_FILLING_FOK;
            OrderSend(request, result);

I expect something simple too.

Thanks for help. 

You can send a ordersend with the opposite direction to close the trade 

/
To add comments, please log in or register