voidOnStart()
{
datetime from=0;
datetime to=TimeCurrent();
//--- richiede l'intera cronistoria
HistorySelect(from,to);
//---variabili per la restituzione di valori dalle proprietà dell'ordine
ulong ticket;
double open_price;
double initial_volume;
datetime time_setup;
datetime time_done;
string symbol;
string type;
long order_magic;
long positionID;
//--- numero degli attuali ordini in corso
uint total=HistoryOrdersTotal();
//--- passa attraverso gli ordini in un ciclo
for(uint i=0;i<total;i++)
{
//--- restituisce il ticket dell'ordine per la sua posizione nella lista
if((ticket=HistoryOrderGetTicket(i))>0)
{
//--- restituisce le proprietà dell'ordine
open_price =HistoryOrderGetDouble(ticket,ORDER_PRICE_OPEN);
time_setup =(datetime)HistoryOrderGetInteger(ticket,ORDER_TIME_SETUP);
time_done =(datetime)HistoryOrderGetInteger(ticket,ORDER_TIME_DONE);
symbol =HistoryOrderGetString(ticket,ORDER_SYMBOL);
order_magic =HistoryOrderGetInteger(ticket,ORDER_MAGIC);
positionID =HistoryOrderGetInteger(ticket,ORDER_POSITION_ID);
initial_volume=HistoryOrderGetDouble(ticket,ORDER_VOLUME_INITIAL);
type =GetOrderType(HistoryOrderGetInteger(ticket,ORDER_TYPE));
//--- prepara e mostra le informazioni sull'ordine
printf("#ticket %d %s %G %s at %G era impostato a %s => fatto a %s, pos ID=%d",
ticket, // ticket dell'ordine
type, // tipo
initial_volume, // volume piazzato
symbol, // simbolo
open_price, // prezzo open specificato
TimeToString(time_setup),// orario di piazzamento dell'ordine
TimeToString(time_done), // orario di esecuzione o cancellazione dell'ordine
positionID // ID di una posizione, per cui la quantità dell'ordine è inclusa
);
}
}
//---
}
//+--------------------------------------------------------------------------------+
//| Restituisce il nome stringa del tipo di ordine |
//+--------------------------------------------------------------------------------+
string GetOrderType(long type)
{
string str_type="unknown operation";
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");
}
return(str_type);
}
|