Information über den letzten Deal - Last Deal Information

Einloggen oder registrieren, um einen Kommentar zu schreiben
amando
742
amando  

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


double last_deal_volume(const string symbol,const int magicnumber)
  {
// --- determine the time intervals of the required trading history
   datetime end=TimeCurrent();                 // current server time
   datetime 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 history
   HistorySelect(start,end);
//--- obtain the number of deals in the history
   int deals=HistoryDealsTotal();

   int returns=0;
   double profit=0;
   double loss=0;
   double deal_volume=0;
//--- scan through all of the deals in the history
   if(deals>0)
     {
      for(int i=deals-1;i<deals;i++)
         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
        {
         //--- obtain the ticket of the deals by its index in the list
         ulong 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_MAGIC
            if(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 calculations
   return(deal_volume);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double last_deal_time(const string symbol,const int magicnumber)
  {
// --- determine the time intervals of the required trading history
   datetime end=TimeCurrent();                 // current server time
   datetime 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 history
   HistorySelect(start,end);
//--- obtain the number of deals in the history
   int deals=HistoryDealsTotal();

   ulong deal_time=0;
//--- scan through all of the deals in the history
   if(deals>0)
     {
      for(int i=0;i<deals;i++)
         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
        {

         //--- obtain the ticket of the deals by its index in the list
         ulong 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_MAGIC
            if(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 calculations

   return((ulong)deal_time);

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double last_deal_profit(const string symbol,const int magicnumber)
  {
// --- determine the time intervals of the required trading history
   datetime end=TimeCurrent();                 // current server time
   datetime 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 history
   HistorySelect(start,end);
//--- obtain the number of deals in the history
   int deals=HistoryDealsTotal();

   double deal_profit=0;
//--- scan through all of the deals in the history
   if(deals>0)
     {
      for(int i=deals-1;i<deals;i++)
         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
        {
         //--- obtain the ticket of the deals by its index in the list
         ulong 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_MAGIC
            if(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 calculations
   return(deal_profit);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double last_deal_direction(const string symbol,const int magicnumber)
  {
// --- determine the time intervals of the required trading history
   datetime end=TimeCurrent();                 // current server time
   datetime 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 history
   HistorySelect(start,end);
//--- obtain the number of deals in the history
   int deals=HistoryDealsTotal();

   int deal_direction=-1;
//--- scan through all of the deals in the history
   if(deals>0)
     {
      for(int i=deals-1;i<deals;i++)
         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
        {
         //--- obtain the ticket of the deals by its index in the list
         ulong 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_MAGIC
            if(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 calculations

   return((int)deal_direction);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

double last_deal_reason(const string symbol,const int magicnumber)
  {
// --- determine the time intervals of the required trading history
   datetime end=TimeCurrent();                 // current server time
   datetime 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 history
   HistorySelect(start,end);
//--- obtain the number of deals in the history
   int deals=HistoryDealsTotal();

   ulong deal_reason=0;
//--- scan through all of the deals in the history
   if(deals>0)
     {
      for(int i=deals-1;i<deals;i++)
         //+------------------------------------------------------------------+
         //|                                                                  |
         //+------------------------------------------------------------------+
        {
         //--- obtain the ticket of the deals by its index in the list
         ulong 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_MAGIC
            if(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 calculations

   return((int)deal_reason);
  }

dann noch viel spass damit

Einloggen oder registrieren, um einen Kommentar zu schreiben