#define TICKET 1819621374 // Beispiel einer Ticketnummer einer bekannten Order aus der Kontohistorie
//+------------------------------------------------------------------+
//| Skript Programm Start Funktion |
//+------------------------------------------------------------------+
void OnStart()
{
//--- wähle eine historische Order anhand des in TICKET angegebenen Ticketnummer
if(!HistoryOrderSelect(TICKET))
{
PrintFormat("HistoryOrderSelect(%I64u) failed. Error %d", TICKET, GetLastError());
return;
}
//--- wenn eine Order erfolgreich ausgewählt wurde, ruf deren Daten ab und druck die Order-Beschreibung im Journal aus
ENUM_ORDER_TYPE order_type = (ENUM_ORDER_TYPE)HistoryOrderGetInteger(TICKET, ORDER_TYPE);
ENUM_ORDER_STATE order_state = (ENUM_ORDER_STATE)HistoryOrderGetInteger(TICKET, ORDER_STATE);
ENUM_ORDER_REASON order_reason= (ENUM_ORDER_REASON)HistoryOrderGetInteger(TICKET, ORDER_REASON);
long order_time = HistoryOrderGetInteger(TICKET, ORDER_TIME_SETUP_MSC);
string order_symbol=HistoryOrderGetString(TICKET, ORDER_SYMBOL);
double order_vol_init=HistoryOrderGetDouble(TICKET, ORDER_VOLUME_INITIAL);
double order_vol_curr=HistoryOrderGetDouble(TICKET, ORDER_VOLUME_CURRENT);
PrintFormat("%s Order %.2f/%s %s #%I64u %s by %s at %s",
order_symbol, order_vol_init, (order_vol_curr>0 ? DoubleToString(order_vol_curr,2) : "0"),
OrderTypeDescription(order_type), TICKET, OrderStateDescription(order_state),
OrderReasonDescription(order_reason), TimeMscToString(order_time));
/*
Ergebnis für verschiedene angegebene Tickets:
EURUSD Order 0.50/0.50 Buy Limit #2812894647 Canceled by Client at 2024.09.04 19:02:31.793
EURUSD Order 0.10/0 Sell #1753011743 Filled by Take Profit at 2023.06.12 17:04:20.353
GBPUSD Order 0.10/0 Buy #1819621374 Filled by Client at 2023.07.24 06:16:25.746
*/
}
//+------------------------------------------------------------------+
//| Rückgabe der Beschreibung des Auftragstyps |
//+------------------------------------------------------------------+
string OrderTypeDescription(const ENUM_ORDER_TYPE type)
{
switch(type)
{
case ORDER_TYPE_BUY : return("Buy");
case ORDER_TYPE_SELL : return("Sell");
case ORDER_TYPE_BUY_LIMIT : return("Buy Limit");
case ORDER_TYPE_SELL_LIMIT : return("Sell Limit");
case ORDER_TYPE_BUY_STOP : return("Buy Stop");
case ORDER_TYPE_SELL_STOP : return("Sell Stop");
case ORDER_TYPE_BUY_STOP_LIMIT : return("Buy Stop Limit");
case ORDER_TYPE_SELL_STOP_LIMIT : return("Sell Stop Limit");
default : return("Unknown order type: "+(string)type);
}
}
//+------------------------------------------------------------------+
//| Rückgabe der Beschreibung des Order-Status |
//+------------------------------------------------------------------+
string OrderStateDescription(ENUM_ORDER_STATE state)
{
switch(state)
{
case ORDER_STATE_STARTED : return("Started");
case ORDER_STATE_PLACED : return("Placed");
case ORDER_STATE_CANCELED : return("Canceled");
case ORDER_STATE_PARTIAL : return("Partial");
case ORDER_STATE_FILLED : return("Filled");
case ORDER_STATE_REJECTED : return("Rejected");
case ORDER_STATE_EXPIRED : return("Expired");
case ORDER_STATE_REQUEST_ADD : return("Request Add");
case ORDER_STATE_REQUEST_MODIFY : return("Request Modify");
case ORDER_STATE_REQUEST_CANCEL : return("Request Cancel");
default : return("Unknown state: "+(string)state);
}
}
//+------------------------------------------------------------------+
//| Rückgabe der Beschreibung des Order-Grundes |
//+------------------------------------------------------------------+
string OrderReasonDescription(const ENUM_ORDER_REASON reason)
{
switch(reason)
{
case ORDER_REASON_CLIENT : return("Client");
case ORDER_REASON_MOBILE : return("Mobile");
case ORDER_REASON_WEB : return("Web");
case ORDER_REASON_EXPERT : return("Expert");
case ORDER_REASON_SL : return("Stop Loss");
case ORDER_REASON_TP : return("Take Profit");
case ORDER_REASON_SO : return("Stop Out");
default : return("Unknown reason: "+(string)reason);
}
}
//+------------------------------------------------------------------+
//| Rückgabe der Zeit in Millisekunden |
//+------------------------------------------------------------------+
string TimeMscToString(const long time_msc, int flags=TIME_DATE|TIME_MINUTES|TIME_SECONDS)
{
return(TimeToString(time_msc/1000, flags) + "." + IntegerToString(time_msc %1000, 3, '0'));
}
|