//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- in un ciclo dalla lista di tutti gli ordini del conto
int total=OrdersTotal();
for(int i=0; i<total; i++)
{
//--- ottenere il ticket dell'ordine nella lista tramite l'indice del ciclo
ulong ticket=OrderGetTicket(i);
if(ticket==0)
continue;
//--- ottenere il tipo di ordine e visualizzare l'intestazione per la lista delle proprietà reali dell'ordine selezionato
string type=OrderTypeDescription((ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE));
PrintFormat("Double properties of an active pending order %s #%I64u:", type, ticket);
//--- stampare tutte le proprietà reali dell'ordine selezionato sotto l'intestazione
OrderPropertiesDoublePrint(16);
}
/*
risultato:
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
*/
}
//+------------------------------------------------------------------+
//| Restituire la descrizione del tipo di ordine |
//+------------------------------------------------------------------+
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");
}
}
//+-----------------------------------------------------------------------------------------------+
//| Visualizzare le proprietà effettivo dell'ordine selezionato nel journal |
//+-----------------------------------------------------------------------------------------------+
void OrderPropertiesDoublePrint(const uint header_width=0)
{
//--- ottenere il simbolo dell'ordine e il numero di decimali per il simbolo
string symbol = OrderGetString(ORDER_SYMBOL);
int digits = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
//--- visualizzare il volume iniziale quando si piazza un ordine con una intestazione della larghezza specificata nel journal
OrderPropertyPrint("Volume initial:",header_width,2,ORDER_VOLUME_INITIAL);
//--- visualizzare il volume dell'ordine non evaso nel journal
OrderPropertyPrint("Volume current:",header_width,2,ORDER_VOLUME_CURRENT);
//--- visualizzare il prezzo, specificato nell'ordine, nel journal
OrderPropertyPrint("Price open:",header_width,digits,ORDER_PRICE_OPEN);
//--- visualizzare il livello dello StopLoss nel journal
OrderPropertyPrint("StopLoss:",header_width,digits,ORDER_SL);
//--- visualizzare il livello del TakeProfit nel journal
OrderPropertyPrint("TakeProfit:",header_width,digits,ORDER_TP);
//--- visualizzare il prezzo corrente tramite simbolo dell'ordine nel journal
OrderPropertyPrint("Price current:",header_width,digits,ORDER_PRICE_CURRENT);
//--- visualizzare nel journal il prezzo dell'ordine StopLimit, quando l'ordine StopLimit viene attivato
OrderPropertyPrint("StopLimit:",header_width,digits,ORDER_PRICE_STOPLIMIT);
}
//+------------------------------------------------------------------------+
//| Visualizzare il valore effettivo dell'ordine nel journal |
//+------------------------------------------------------------------------+
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
{
//--- se la larghezza dell'intestazione passata alla funzione è uguale a zero, allora la larghezza sarà la dimensione della riga dell'intestazione + 1
uint w=(header_width==0 ? header.Length()+1 : header_width);
PrintFormat("%-*s%-.*f", w, header, digits, value);
}
}
|