//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- boucle sur tous les ordres du compte
int total=OrdersTotal();
for(int i=0; i<total; i++)
{
//--- récupère le ticket de l'ordre dans la liste par son index
ulong ticket=OrderGetTicket(i);
if(ticket==0)
continue;
//--- récupère le type de l'ordre et affiche l'en-tête de la liste des propriétés réelles de l'ordre sélectionné
string type=OrderTypeDescription((ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE));
PrintFormat("Double properties of an active pending order %s #%I64u:", type, ticket);
//--- affiche toutes les propriétés réelles de l'ordre sélectionné sous l'en-tête
OrderPropertiesDoublePrint(16);
}
/*
résultat :
Double properties of an active pending order Sell Limit #2812000714:
Volume initial: 1.00
Volume current: 1.00
Price open: 145.282
StopLoss: 0.000
TakeProfit: 0.000
Price current: 145.044
StopLimit: 0.000
Double properties of an active pending order Buy Limit #2812001112:
Volume initial: 1.00
Volume current: 1.00
Price open: 144.836
StopLoss: 0.000
TakeProfit: 0.000
Price current: 145.051
StopLimit: 0.000
Double properties of an active pending order Buy Stop #2812001488:
Volume initial: 0.50
Volume current: 0.50
Price open: 1.10642
StopLoss: 0.00000
TakeProfit: 0.00000
Price current: 1.10530
StopLimit: 0.00000
Double properties of an active pending order Sell Stop #2812001712:
Volume initial: 0.50
Volume current: 0.50
Price open: 1.10374
StopLoss: 0.00000
TakeProfit: 0.00000
Price current: 1.10525
StopLimit: 0.00000
*/
}
//+------------------------------------------------------------------+
//| Retourne la description du type de l'ordre |
//+------------------------------------------------------------------+
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");
}
}
//+------------------------------------------------------------------+
//| Affiche dans le journal les propriétés réelles de l'ordre |
//+------------------------------------------------------------------+
void OrderPropertiesDoublePrint(const uint header_width=0)
{
//--- récupère le symbole de l'ordre et le nombre de décimales du symbole
string symbol = OrderGetString(ORDER_SYMBOL);
int digits = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
//--- affiche dans le journal le volume initial lors du passage d'un ordre avec un en-tête de la largeur spécifiée
OrderPropertyPrint("Volume initial:",header_width,2,ORDER_VOLUME_INITIAL);
//--- affiche dans le journal le volume des ordres non exécutés
OrderPropertyPrint("Volume current:",header_width,2,ORDER_VOLUME_CURRENT);
//---affiche dans le journal le prix spécifié dans l'ordre
OrderPropertyPrint("Price open:",header_width,digits,ORDER_PRICE_OPEN);
//--- affiche dans le journal le niveau du StopLoss
OrderPropertyPrint("StopLoss:",header_width,digits,ORDER_SL);
//--- affiche dans le journal le niveau du TakeProfit
OrderPropertyPrint("TakeProfit:",header_width,digits,ORDER_TP);
//--- affiche dans le journal le prix courant du symbol de l'ordre
OrderPropertyPrint("Price current:",header_width,digits,ORDER_PRICE_CURRENT);
//--- affiche dans le journal le prix de l'ordre Limit, lorsque l'ordre StopLimit est activé
OrderPropertyPrint("StopLimit:",header_width,digits,ORDER_PRICE_STOPLIMIT);
}
//+------------------------------------------------------------------+
//| Affiche dans le journal la propriété de type réel de l'ordre |
//+------------------------------------------------------------------+
void OrderPropertyPrint(const string header, uint header_width, int digits, ENUM_ORDER_PROPERTY_DOUBLE property)
{
double value=0;
if(!OrderGetDouble(property, value))
PrintFormat("Cannot get property %s, error=%d", EnumToString(property), GetLastError());
else
{
//--- si la largeur de l'en-tête est passée à la fonction égale à zéro, alors la largeur sera la taille de la ligne d'en-tête + 1
uint w=(header_width==0 ? header.Length()+1 : header_width);
PrintFormat("%-*s%-.*f", w, header, digits, value);
}
}
|