Download MetaTrader 5

Close my trader MqlTradeRequest

To add comments, please log in or register
Having questions? Ask them on the Forum - traders will help you!
snakzbenjy
21
snakzbenjy 2012.04.03 02:33 

Hello,

I place a trade with MqlTradeRequest structure and i want close my trade (Order = 123456 example)

When i write it :

MqlTradeRequest request={0};
   request.action=TRADE_ACTION_MODIFY;        
   request.magic=mymagic_number;       
   request.symbol = mysymbol;            
   request.volume = myvolume;       
   request.order =123456;               
   request.sl=0;                 
   request.tp=0;               
   request.type= ORDER_TYPE_BUY_STOP;                  
   request.price=GetCurrentPrice(request.type);
   MqlTradeResult result={0};
   OrderSend(request,result); 

 my order is not close ? 

do you know why

 thank a lot

Benjamin 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure - Documentation on MQL5
Biantoro Kunarto
14805
Biantoro Kunarto 2012.04.03 04:59  

I'm not sure about this, but you can change this


Biantoro Kunarto
14805
Biantoro Kunarto 2012.04.03 05:01  

I'm not sure about this, but you can change this for 

closing buy position

request.action=TRADE_ACTION_DEAL; 
request.type= ORDER_TYPE_SELL;

closing sell position

request.action=TRADE_ACTION_DEAL; 
request.type= ORDER_TYPE_BUY; 

snakzbenjy
21
snakzbenjy 2012.04.03 20:16  
biantoro:

I'm not sure about this, but you can change this for 

closing buy position

closing sell position

This it's for placed order no?

For close my order i need write :  TRADE_ACTION_MODIFY?

In the doc it's not write how use MqlTradeRequest for close Order

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure - Documentation on MQL5
snakzbenjy
21
snakzbenjy 2012.04.04 02:00  

It's working

For close Buy => Use Sell

For close Sell => Use Buy 

snakzbenjy
21
snakzbenjy 2012.04.04 02:20  

But how can i have two positions for the same Symbol?

example 1 volume Buy and 2 volume sell? 

Biantoro Kunarto
14805
Biantoro Kunarto 2012.04.04 03:33  
snakzbenjy:

But how can i have two positions for the same Symbol?

example 1 volume Buy and 2 volume sell? 

In MQL5 you can't have 2 position (buy and sell). Only 1 position buy or sell..
To add comments, please log in or register