Skip to content

Commit

Permalink
Final fix for orders are opened instead of being closed for both MT4 …
Browse files Browse the repository at this point in the history
…and MT5 (fixes GH-707)
  • Loading branch information
kenorb committed Aug 12, 2023
1 parent d7908ac commit f99f420
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Order.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,7 @@ class Order : public SymbolInfo {
_request.symbol = odata.Get(ORDER_SYMBOL);
_request.type = NegateOrderType(odata.Get<ENUM_ORDER_TYPE>(ORDER_TYPE));
_request.type_filling = GetOrderFilling(odata.Get(ORDER_SYMBOL));
_request.position =
odata.Get<ulong>(ORDER_POSITION_ID) > 0 ? odata.Get<ulong>(ORDER_POSITION_ID) : odata.Get<ulong>(ORDER_TICKET);
_request.position = odata.Get<ulong>(ORDER_PROP_TICKET);
_request.price = SymbolInfo::GetCloseOffer(odata.Get<ENUM_ORDER_TYPE>(ORDER_TYPE));
_request.volume = odata.Get<double>(ORDER_VOLUME_CURRENT);
Order::OrderSend(_request, oresult, oresult_check);
Expand Down
8 changes: 7 additions & 1 deletion Order.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ struct OrderData {
return (T)type_time;
case ORDER_MAGIC:
return (T)magic;
#ifndef __MQL4__
case ORDER_POSITION_ID:
return (T)position_id;
case ORDER_POSITION_BY_ID:
Expand All @@ -391,6 +392,7 @@ struct OrderData {
return (T)reason;
case ORDER_TICKET:
return (T)ticket;
#endif
}
SetUserError(ERR_INVALID_PARAMETER);
return WRONG_VALUE;
Expand Down Expand Up @@ -500,7 +502,9 @@ struct OrderData {
return "???";
}
// Setters.
void IncCloseTries() { close_tries++; }
void IncCloseTries() {
close_tries++;
}
template <typename T>
void Set(ENUM_ORDER_PROPERTY_CUSTOM _prop_name, T _value) {
switch (_prop_name) {
Expand Down Expand Up @@ -609,6 +613,7 @@ struct OrderData {
case ORDER_MAGIC:
magic = _value;
return;
#ifndef __MQL4__
case ORDER_POSITION_ID:
position_id = _value;
return;
Expand All @@ -621,6 +626,7 @@ struct OrderData {
case ORDER_TICKET:
ticket = _value;
return;
#endif
}
SetUserError(ERR_INVALID_PARAMETER);
}
Expand Down

0 comments on commit f99f420

Please sign in to comment.