nachdem ich ja mal gesucht habe, wie ich die Informationen über den letzen Deal herausbekomme
ACHTUNG: Deal nicht order
hier habt ihr die Codebase, die Variablen müsst ihr selber setzen
double last_deal_volume(conststring symbol,constint magicnumber)
{
// --- determine the time intervals of the required trading historydatetime end=TimeCurrent(); // current server timedatetime start=end-PeriodSeconds(PERIOD_H1) *Hours_Order_loockback;// set the beginning time to 24 hours ago//--- request in the cache of the program the needed interval of the trading historyHistorySelect(start,end);
//--- obtain the number of deals in the historyint deals=HistoryDealsTotal();
int returns=0;
double profit=0;
double loss=0;
double deal_volume=0;
//--- scan through all of the deals in the historyif(deals>0)
{
for(int i=deals-1;i<deals;i++)
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+
{
//--- obtain the ticket of the deals by its index in the listulong deal_ticket=HistoryDealGetTicket(i);
if(deal_ticket>0) // obtain into the cache the deal, and work with it
{
string deal_symbol=HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
ulong time=HistoryDealGetInteger(deal_ticket,DEAL_TIME);
ulong order =HistoryDealGetInteger(deal_ticket,DEAL_ORDER);
long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
long pos_ID =HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID);
//--- process the deals with the indicated DEAL_MAGICif(order_magic==magicnumber && deal_symbol==symbol)
{
deal_volume=HistoryDealGetDouble(deal_ticket,DEAL_VOLUME);
}
//--- calculate the losses and profits with a fixed results
}
else// unsuccessful attempt to obtain a deal
{
PrintFormat("We couldn't select a deal, with the index %d. Error %d",
i,GetLastError());
Print("Last Deal Volume");
}
}
}
//--- output the results of the calculationsreturn(deal_volume);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+double last_deal_time(conststring symbol,constint magicnumber)
{
// --- determine the time intervals of the required trading historydatetime end=TimeCurrent(); // current server timedatetime start=end-PeriodSeconds(PERIOD_H1) *Hours_Order_loockback;// set the beginning time to 24 hours ago//--- request in the cache of the program the needed interval of the trading historyHistorySelect(start,end);
//--- obtain the number of deals in the historyint deals=HistoryDealsTotal();
ulong deal_time=0;
//--- scan through all of the deals in the historyif(deals>0)
{
for(int i=0;i<deals;i++)
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+
{
//--- obtain the ticket of the deals by its index in the listulong deal_ticket=HistoryDealGetTicket(i);
if(deal_ticket>0) // obtain into the cache the deal, and work with it
{
string deal_symbol=HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
long order_magic=HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
//--- process the deals with the indicated DEAL_MAGICif(order_magic==magicnumber && deal_symbol==symbol)
{
deal_time=HistoryDealGetInteger(deal_ticket,DEAL_TIME);
}
}
else// unsuccessful attempt to obtain a deal
{
PrintFormat("We couldn't select a deal, with the index %d. Error %d",
i,GetLastError());
Print("Last Deal Time");
}
}
}
//--- output the results of the calculationsreturn((ulong)deal_time);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+double last_deal_profit(conststring symbol,constint magicnumber)
{
// --- determine the time intervals of the required trading historydatetime end=TimeCurrent(); // current server timedatetime start=end-PeriodSeconds(PERIOD_H1)*Hours_Order_loockback;// set the beginning time to 24 hours ago//--- request in the cache of the program the needed interval of the trading historyHistorySelect(start,end);
//--- obtain the number of deals in the historyint deals=HistoryDealsTotal();
double deal_profit=0;
//--- scan through all of the deals in the historyif(deals>0)
{
for(int i=deals-1;i<deals;i++)
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+
{
//--- obtain the ticket of the deals by its index in the listulong deal_ticket=HistoryDealGetTicket(i);
if(deal_ticket>0) // obtain into the cache the deal, and work with it
{
string deal_symbol =HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
//--- process the deals with the indicated DEAL_MAGICif(order_magic==magicnumber && deal_symbol==symbol)
{
deal_profit=HistoryDealGetDouble(deal_ticket,DEAL_PROFIT);
}
}
else// unsuccessful attempt to obtain a deal
{
PrintFormat("We couldn't select a deal, with the index %d. Error %d",
i,GetLastError());
Print("Last Deal Profit");
}
}
}
//--- output the results of the calculationsreturn(deal_profit);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+double last_deal_direction(conststring symbol,constint magicnumber)
{
// --- determine the time intervals of the required trading historydatetime end=TimeCurrent(); // current server timedatetime start=end-PeriodSeconds(PERIOD_H1)*Hours_Order_loockback;// set the beginning time to 24 hours ago//--- request in the cache of the program the needed interval of the trading historyHistorySelect(start,end);
//--- obtain the number of deals in the historyint deals=HistoryDealsTotal();
int deal_direction=-1;
//--- scan through all of the deals in the historyif(deals>0)
{
for(int i=deals-1;i<deals;i++)
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+
{
//--- obtain the ticket of the deals by its index in the listulong deal_ticket=HistoryDealGetTicket(i);
if(deal_ticket>0) // obtain into the cache the deal, and work with it
{
string deal_symbol =HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
//--- process the deals with the indicated DEAL_MAGICif(order_magic==magicnumber && deal_symbol==symbol)
{
deal_direction=(int)HistoryDealGetInteger(deal_ticket,DEAL_TYPE);
}
}
else// unsuccessful attempt to obtain a deal
{
PrintFormat("We couldn't select a deal, with the index %d. Error %d",
i,GetLastError());
Print("Last Deal Direction");
}
}
}
//--- output the results of the calculationsreturn((int)deal_direction);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+//+------------------------------------------------------------------+double last_deal_reason(conststring symbol,constint magicnumber)
{
// --- determine the time intervals of the required trading historydatetime end=TimeCurrent(); // current server timedatetime start=end-PeriodSeconds(PERIOD_H1)*Hours_Order_loockback;// set the beginning time to 24 hours ago//--- request in the cache of the program the needed interval of the trading historyHistorySelect(start,end);
//--- obtain the number of deals in the historyint deals=HistoryDealsTotal();
ulong deal_reason=0;
//--- scan through all of the deals in the historyif(deals>0)
{
for(int i=deals-1;i<deals;i++)
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+
{
//--- obtain the ticket of the deals by its index in the listulong deal_ticket=HistoryDealGetTicket(i);
if(deal_ticket>0) // obtain into the cache the deal, and work with it
{
string deal_symbol =HistoryDealGetString(deal_ticket,DEAL_SYMBOL);
long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
//--- process the deals with the indicated DEAL_MAGICif(order_magic==magicnumber && deal_symbol==symbol)
{
deal_reason=HistoryDealGetInteger(deal_ticket,DEAL_REASON);
}
}
else// unsuccessful attempt to obtain a deal
{
PrintFormat("We couldn't select a deal, with the index %d. Error %d",
i,GetLastError());
Print("Last Deal Reason");
}
}
}
//--- output the results of the calculationsreturn((int)deal_reason);
}
Wenn Sie kein Benutzerkonto haben, registrieren Sie sich
Erlauben Sie die Verwendung von Cookies, um sich auf der Website MQL5.com anzumelden.
Bitte aktivieren Sie die notwendige Einstellung in Ihrem Browser, da Sie sich sonst nicht einloggen können.
Sie sind angemeldet. Die Zwei-Faktor-Authentifizierung wurde deaktiviert. Richten Sie sie erneut ein und scannen Sie einen neuen QR-Code oder fahren Sie mit deaktivierter Zwei-Faktor-Authentifizierung fort.
Heute hab ich was für euch,
nachdem ich ja mal gesucht habe, wie ich die Informationen über den letzen Deal herausbekomme
ACHTUNG: Deal nicht order
hier habt ihr die Codebase, die Variablen müsst ihr selber setzen
dann noch viel spass damit