Just look at ..\Include\Trade\Trade.mqh how it closes partially a position, one for hedge, oner for netting accounts:
bool PositionClosePartial(const string symbol,const double volume,const ulong deviation=ULONG_MAX); bool PositionClosePartial(const ulong ticket,const double volume,const ulong deviation=ULONG_MAX);
Thanks, but could you tell please where is this file ? I am using metatrader5 on windows 10
I mean, where is this file in my system ? If I go in C:\Program Files\MetaTrader 5 I don't see such path
AYMERIC75 #:
I mean, where is this file in my system ? If I go in C:\Program Files\MetaTrader 5 I don't see such path
I mean, where is this file in my system ? If I go in C:\Program Files\MetaTrader 5 I don't see such path
It's a sub-folder of MQL5 data folder.
Forum on trading, automated trading systems and testing trading strategies
Invalid License for all EA (even free ones)
Miguel Angel Vico Alba, 2023.04.26 20:50
Do a Crtl+Shift+D on the terminal or go to the 'File\Open Data Folder' ...
Thanks a lot!
I have tried to replicate what is on this Trade.mqh file:
request = { "type" : MetaTrader5.ORDER_TYPE_SELL, "price" : MetaTrader5.symbol_info_tick(symbol).bid, "action" : MetaTrader5.TRADE_ACTION_DEAL, "symbol" : symbol, "volume" : 0.005, "position" : position_ticket, }
But I get "Unsupported filling mode"
Then I tried, to add
"type_filling": MetaTrader5.ORDER_FILLING_RETURN, also with ORDER_FILLING_IOC and ORDER_FILLING_FOK but still the same
AYMERIC75 #:
I have tried to replicate what is on this Trade.mqh file:
But I get "Unsupported filling mode"
Then I tried, to add
"type_filling": MetaTrader5.ORDER_FILLING_RETURN, also with ORDER_FILLING_IOC and ORDER_FILLING_FOK but still the same
?? Can you read? In my version of e.g.:
//+------------------------------------------------------------------+ //| Partial close specified opened position (for hedging mode only) | //+------------------------------------------------------------------+ bool CTrade::PositionClosePartial(const string symbol,const double volume,const ulong deviation)
I read:
... //--- check volume double position_volume=PositionGetDouble(POSITION_VOLUME); if(position_volume>volume) position_volume=volume; //--- setting request m_request.action =TRADE_ACTION_DEAL; m_request.symbol =symbol; m_request.volume =position_volume; m_request.magic =m_magic; m_request.deviation=(deviation==ULONG_MAX) ? m_deviation : deviation; m_request.position =PositionGetInteger(POSITION_TICKET); ...
the only difference with mine is request.magic and request.deviation that re added, I have tried to add deviation but still the same, magic is just a ref to the strategy, anyway I will try to add it too
same, not working
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I am opening an Buy order with:
I receive this response:
Then, I am sending a close order with:
Where "position" is the number of the buy order...
And I receive an error:
Any idea why I am getting this "Invalid request" error ?
Thanks