Download MetaTrader 5

How to close a position with mql5 ?

To add comments, please log in or register
Alain Verleyen
Moderator
31085
Alain Verleyen 2016.04.19 15:11 
Comments that do not relate to the "Close all position function", have been moved into this topic.
edxxgardo
20
edxxgardo 2016.04.19 10:45  

Hi, sorry for my ignorance.

 

I'm using MetaTrader 5 and of course its Editor to write a simple EA.

If I have this order running:

mrequest.action = TRADE_ACTION_DEAL;                                    // immediate order execution

            mrequest.price = NormalizeDouble(latest_price.ask,_Digits);             // latest ask price

            mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits);   // Stop Loss

            //mrequest.tp = NormalizeDouble(latest_price.ask + 0*_Point,_Digits);     // Take Profit

            mrequest.symbol = _Symbol;                                              // currency pair

            mrequest.volume = Lot;                                                  // number of lots to trade

            mrequest.magic = EA_Magic;                                              // Order Magic Number

            mrequest.type = ORDER_TYPE_BUY;                                         // Buy Order

            mrequest.type_filling = ORDER_FILLING_FOK;                              // Order execution type

            mrequest.deviation=100;                                                 // Deviation from current price

            //--- send order

            OrderSend(mrequest,mresult); 

 


 

 

Ho can I close it? There is not OpenClose() or similar function in the Editor. I get the error message saying that the "function is not defined". Any help will be appreciated.

Thx 

To add comments, please log in or register