Skip to content

Commit

Permalink
Order: OrderData: Adds property to calculate profit in base currency …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
kenorb committed Sep 13, 2021
1 parent ae95b29 commit caa9828
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Order.enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ enum ENUM_ORDER_PROPERTY_CUSTOM {
ORDER_PROP_PROFIT, // Current profit in price difference.
ORDER_PROP_PROFIT_PIPS, // Current profit in pips.
ORDER_PROP_PROFIT_TOTAL, // Total profit (profit minus fees).
ORDER_PROP_PROFIT_VALUE, // Total profit in base currency value.
ORDER_PROP_REASON_CLOSE, // Reason or source for closing an order.
ORDER_PROP_TICKET, // Ticket number.
ORDER_PROP_TIME_CLOSED, // Closed time.
Expand Down
3 changes: 3 additions & 0 deletions Order.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ struct OrderData {
// Getters.
template <typename T>
T Get(ENUM_ORDER_PROPERTY_CUSTOM _prop_name) {
double _tick_value = SymbolInfoStatic::GetTickValue(symbol);
switch (_prop_name) {
case ORDER_PROP_COMMISSION:
return (T)commission;
Expand All @@ -274,6 +275,8 @@ struct OrderData {
return (T)profit;
case ORDER_PROP_PROFIT_PIPS:
return (T)(profit * pow(10, SymbolInfoStatic::GetDigits(symbol)));
case ORDER_PROP_PROFIT_VALUE:
return (T)(Get<int>(ORDER_PROP_PROFIT_PIPS) * volume_curr * SymbolInfoStatic::GetTickValue(symbol));
case ORDER_PROP_PROFIT_TOTAL:
return (T)(profit - total_fees);
case ORDER_PROP_REASON_CLOSE:
Expand Down

0 comments on commit caa9828

Please sign in to comment.