Schau, wie man Roboter kostenlos herunterladen kann

Interessantes Skript?
Veröffentliche einen Link auf das Skript, damit die anderen ihn auch nutzen können

Hat Ihnen das Skript gefallen?
Bewerten Sie es im Terminal MetaTrader 5

Skripte

Order - Deals - Position - Histroy - Skript für den MetaTrader 5

amando

Ansichten:
54
Rating:
Veröffentlicht:
2020.01.15 16:49
//+------------------------------------------------------------------+
//|                                                  export_V1.1.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "https://www.mql5.com/de/users/amando"
#property link      "https://www.mql5.com/de/users/amando"
#property version   "1.1"
#property script_show_inputs



input datetime Start= D'01.01.2019'; // Datum um History zu selektieren
input datetime End  = D'31.12.2999'; // Datum um History zu selektieren
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {

   HistorySelect(Start, End);
   int deals=HistoryDealsTotal();

   FileDelete("HistoryDeals.csv");
   int h=FileOpen("HistoryDeals.csv", FILE_READ|FILE_WRITE|FILE_ANSI|FILE_CSV);
   if(h!=INVALID_HANDLE)
     {
      FileWriteString(h, "Symbol;External ID;Comment;Magic;Entry;Order;Positions ID;Reason;Deal Ticket;Zeit;Zeit GMT;Type;Volume;Price;Commission;Profit;Swap;Tag;Monat;Jahr;Stunde;Minute"+"\r\n");

      if(deals>0)
        {
         for(int i=deals-1; i>=0; i--)
           {

            ulong ticket=HistoryDealGetTicket(i);
            if(ticket>0)
              {
               string externalid             =HistoryDealGetString(ticket, DEAL_EXTERNAL_ID);
               string comment                =HistoryDealGetString(ticket, DEAL_COMMENT);
               string symbol                 =HistoryDealGetString(ticket, DEAL_SYMBOL);
               long  magic                   =HistoryDealGetInteger(ticket, DEAL_MAGIC);
               ENUM_DEAL_ENTRY entry         =(ENUM_DEAL_ENTRY)HistoryDealGetInteger(ticket, DEAL_ENTRY);
               long order                    =HistoryDealGetInteger(ticket, DEAL_ORDER);
               long posid                    =HistoryDealGetInteger(ticket, DEAL_POSITION_ID);
               ENUM_DEAL_REASON reason       =(ENUM_DEAL_REASON)HistoryDealGetInteger(ticket, DEAL_REASON);
               long dealticket               =HistoryDealGetInteger(ticket, DEAL_TICKET);
               datetime time                 =(datetime)HistoryDealGetInteger(ticket, DEAL_TIME);
               long timemsc                  =HistoryDealGetInteger(ticket, DEAL_TIME_MSC);
               ENUM_DEAL_TYPE type           =(ENUM_DEAL_TYPE)HistoryDealGetInteger(ticket, DEAL_TYPE);
               string commission             =(string)HistoryDealGetDouble(ticket, DEAL_COMMISSION);
               string price                  =(string)HistoryDealGetDouble(ticket, DEAL_PRICE);
               string profit                 =(string)HistoryDealGetDouble(ticket, DEAL_PROFIT);
               string swap                   =(string)HistoryDealGetDouble(ticket, DEAL_SWAP);
               string volume                 =(string)HistoryDealGetDouble(ticket, DEAL_VOLUME);

               StringReplace(commission, ".", ",");
               StringReplace(price, ".", ",");
               StringReplace(profit, ".", ",");
               StringReplace(swap, ".", ",");
               StringReplace(volume, ".", ",");

               string entry1 = IntegerToString(entry);
               if(entry1 == "0")
                  StringReplace(entry1, "0", "DEAL_ENTRY_IN");
               if(entry1 == "1")
                  StringReplace(entry1, "1", "DEAL_ENTRY_OUT");
               if(entry1 == "2")
                  StringReplace(entry1, "2", "DEAL_ENTRY_INOUT");
               if(entry1 == "3")
                  StringReplace(entry1, "3", "DEAL_ENTRY_OUT_BY");

               string reason1 = IntegerToString(reason);
               if(reason1 == "0")
                  StringReplace(reason1, "0", "DEAL_REASON_CLIENT");
               if(reason1 == "1")
                  StringReplace(reason1, "1", "DEAL_REASON_MOBILE");
               if(reason1 == "2")
                  StringReplace(reason1, "2", "DEAL_REASON_WEB");
               if(reason1 == "3")
                  StringReplace(reason1, "3", "DEAL_REASON_EXPERT");
               if(reason1 == "4")
                  StringReplace(reason1, "4", "DEAL_REASON_SL");
               if(reason1 == "5")
                  StringReplace(reason1, "5", "DEAL_REASON_TP");
               if(reason1 == "6")
                  StringReplace(reason1, "6", "DEAL_REASON_SO");
               if(reason1 == "7")
                  StringReplace(reason1, "7", "DEAL_REASON_ROLLOVER");
               if(reason1 == "8")
                  StringReplace(reason1, "8", "DEAL_REASON_VMARGIN");
               if(reason1 == "9")
                  StringReplace(reason1, "9", "DEAL_REASON_SPLIT");

               string type1 = IntegerToString(type);
               if(type1 == "0")
                  StringReplace(type1, "0", "DEAL_TYPE_BUY");
               if(type1 == "1")
                  StringReplace(type1, "1", "DEAL_TYPE_SELL");
               if(type1 == "2")
                  StringReplace(type1, "2", "DEAL_TYPE_BALANCE");
               if(type1 == "3")
                  StringReplace(type1, "3", "DEAL_TYPE_CREDIT");
               if(type1 == "4")
                  StringReplace(type1, "4", "DEAL_TYPE_CHARGE");
               if(type1 == "5")
                  StringReplace(type1, "5", "DEAL_TYPE_CORRECTION");
               if(type1 == "6")
                  StringReplace(type1, "6", "DEAL_TYPE_BONUS");
               if(type1 == "7")
                  StringReplace(type1, "7", "DEAL_TYPE_COMMISSION");
               if(type1 == "8")
                  StringReplace(type1, "8", "DEAL_TYPE_COMMISSION_DAILY");
               if(type1 == "9")
                  StringReplace(type1, "9", "DEAL_TYPE_COMMISSION_MONTHLY");
               if(type1 == "10")
                  StringReplace(type1, "10", "DEAL_TYPE_COMMISSION_AGENT_DAILY");
               if(type1 == "11")
                  StringReplace(type1, "11", "DEAL_TYPE_COMMISSION_AGENT_MONTHLY");
               if(type1 == "12")
                  StringReplace(type1, "12", "DEAL_TYPE_INTEREST");
               if(type1 == "13")
                  StringReplace(type1, "13", "DEAL_TYPE_BUY_CANCELED");
               if(type1 == "14")
                  StringReplace(type1, "14", "DEAL_TYPE_SELL_CANCELED");
               if(type1 == "15")
                  StringReplace(type1, "15", "DEAL_DIVIDEND");
               if(type1 == "16")
                  StringReplace(type1, "16", "DEAL_DIVIDEND_FRANKED");
               if(type1 == "17")
                  StringReplace(type1, "17", "DEAL_TAX");

               string Datum  = TimeToString(time);
               string Tag    = StringSubstr(Datum, 8, 2);
               string Monat  = StringSubstr(Datum, 5, 2);
               string Jahr   = StringSubstr(Datum, 0, 4);
               string Stunde = StringSubstr(Datum, 11, 2);
               string Minute = StringSubstr(Datum, 14, 2);


               FileWriteString(h, symbol+";"+(string)externalid+";"+comment+";"+(string)magic+";"+entry1+";"+(string)order+";"+(string)posid+";"+reason1+";"+(string)dealticket+";"+(string)time+";"+(string)timemsc+";"+type1+";"+(string)volume+";"+(string)price+";"+(string)commission+";"+(string)profit+";"+(string)swap+";"+Tag+";"+Monat+";"+Jahr+";"+Stunde+";"+Minute+ "\r\n");


              }

           }
        }

     }
   FileClose(h);

   int orders=HistoryOrdersTotal();

   FileDelete("HistoryOrders.csv");
   int ho=FileOpen("HistoryOrders.csv", FILE_READ|FILE_WRITE|FILE_ANSI|FILE_CSV);
   if(ho!=INVALID_HANDLE)
     {
      FileWriteString(ho, "Symbol;External ID;Comment;Order Ticket;Zeit Setup Order;Type;Status;Gültig bis;Zeit Ausführung;Zeit Erstellung MSC;Zeit Ausführung MSC;Durchführungstype;Ablaufeigenschaft;Magic;Reason;PosID;PosById;Volume Initial;Volume Current;Open Price;SL;TP;Aktueller Preis;Preis Stop Limit"+"\r\n");

      if(orders>0)
        {
         for(int i=orders-1; i>=0; i--)
           {

            ulong ticket=HistoryOrderGetTicket(i);
            if(ticket>0)
              {
               string symbol                 =HistoryOrderGetString(ticket, ORDER_SYMBOL);
               string comment                =HistoryOrderGetString(ticket, ORDER_COMMENT);
               string externalid             =HistoryOrderGetString(ticket, ORDER_EXTERNAL_ID);

               long orderticket              =HistoryOrderGetInteger(ticket, ORDER_TICKET);
               datetime time                 =(datetime)HistoryOrderGetInteger(ticket, ORDER_TIME_SETUP);
               ENUM_ORDER_TYPE type          =(ENUM_ORDER_TYPE)HistoryOrderGetInteger(ticket, ORDER_TYPE);
               ENUM_ORDER_STATE state        =(ENUM_ORDER_STATE)HistoryOrderGetInteger(ticket, ORDER_STATE);
               datetime expiration           =(datetime)HistoryOrderGetInteger(ticket, ORDER_TIME_EXPIRATION);
               datetime timedone             =(datetime)HistoryOrderGetInteger(ticket, ORDER_TIME_DONE);
               long timesetmsc               =HistoryOrderGetInteger(ticket, ORDER_TIME_SETUP_MSC);
               long timedonemsc              =HistoryOrderGetInteger(ticket, ORDER_TIME_DONE_MSC);
               ENUM_ORDER_TYPE_FILLING filling=(ENUM_ORDER_TYPE_FILLING)HistoryOrderGetInteger(ticket, ORDER_TYPE_FILLING);
               ENUM_ORDER_TYPE_TIME typetime =(ENUM_ORDER_TYPE_TIME)HistoryOrderGetInteger(ticket, ORDER_TYPE_TIME);
               long magic                    =HistoryOrderGetInteger(ticket, ORDER_MAGIC);
               ENUM_ORDER_REASON reason      =(ENUM_ORDER_REASON)HistoryOrderGetInteger(ticket, ORDER_REASON);
               long posid                    =HistoryOrderGetInteger(ticket, ORDER_POSITION_ID);
               long posbyid                  =HistoryOrderGetInteger(ticket, ORDER_POSITION_BY_ID);

               string volumeinititial=(string)HistoryOrderGetDouble(ticket, ORDER_VOLUME_INITIAL);
               string volumecurrent=(string)HistoryOrderGetDouble(ticket, ORDER_VOLUME_CURRENT);
               string priceopen=(string)HistoryOrderGetDouble(ticket, ORDER_PRICE_OPEN);
               string sl=(string)HistoryOrderGetDouble(ticket, ORDER_SL);
               string tp=(string)HistoryOrderGetDouble(ticket, ORDER_TP);
               string pricecurrent=(string)HistoryOrderGetDouble(ticket, ORDER_PRICE_CURRENT);
               string pricestoplimit=(string)HistoryOrderGetDouble(ticket, ORDER_PRICE_STOPLIMIT);

               StringReplace(volumeinititial, ".", ",");
               StringReplace(volumecurrent, ".", ",");
               StringReplace(priceopen, ".", ",");
               StringReplace(sl, ".", ",");
               StringReplace(tp, ".", ",");
               StringReplace(pricestoplimit, ".", ",");
               StringReplace(pricecurrent, ".", ",");

               FileWriteString(ho, symbol+";"+externalid+";"+comment+";"+(string)orderticket+";"+(string)time+";"+(string)type+";"+(string)state+";"+(string)expiration+";"+(string)timedone+";"+(string)timesetmsc+";"+(string)timedonemsc+";"+(string)filling+";"+(string)typetime+";"+(string)magic+";"+(string)reason+";"+(string)posid+";"+(string)posbyid+";"+volumeinititial+";"+volumecurrent+";"+priceopen+";"+sl+";"+tp+";"+pricecurrent+";"+pricestoplimit+"\r\n");

              }

           }
        }

     }
   FileClose(ho);

   int total=PositionsTotal(); // Anzahl offener Positionen
   FileDelete("Positions.csv");
   int hp=FileOpen("Positions.csv", FILE_READ|FILE_WRITE|FILE_ANSI|FILE_CSV);
   if(hp!=INVALID_HANDLE)
     {
      FileWriteString(ho, "Symbol;externalid;Kommentar;Ticketnummer;Zeit;GMT Zeit;Update Zeit;Update Zeit GMT;Richting;Magic;Identifikation;Reason;Volume;OpenPrice;SL;TP;Aktueller Preis;Swap;Profit"+"\r\n");

      for(int i=total-1; i>=0; i--)
        {
         //--- Parameter der Order
         ulong  ticket1=PositionGetTicket(i);// das Ticket der Position
         PositionSelectByTicket(ticket1);

         string symbol=PositionGetString(POSITION_SYMBOL); // Symbol
         string comment=PositionGetString(POSITION_COMMENT);
         string extid=PositionGetString(POSITION_EXTERNAL_ID);

         long ticket=PositionGetInteger(POSITION_TICKET);
         datetime time=(datetime)PositionGetInteger(POSITION_TIME);
         long timemsc =PositionGetInteger(POSITION_TIME_MSC);
         datetime timeupdate=(datetime)PositionGetInteger(POSITION_TIME_UPDATE);
         long timeupdatemsc=PositionGetInteger(POSITION_TIME_UPDATE_MSC);
         ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
         long magic=PositionGetInteger(POSITION_MAGIC);
         long identifier=PositionGetInteger(POSITION_IDENTIFIER);
         ENUM_POSITION_REASON reason=(ENUM_POSITION_REASON) PositionGetInteger(POSITION_REASON);

         string volume=(string)PositionGetDouble(POSITION_VOLUME);
         string open=(string)PositionGetDouble(POSITION_PRICE_OPEN);
         string sl = (string)PositionGetDouble(POSITION_SL);
         string tp = (string)PositionGetDouble(POSITION_TP);
         string pricecurrent=(string)PositionGetDouble(POSITION_PRICE_CURRENT);
         string swap=(string)PositionGetDouble(POSITION_SWAP);
         string profit=(string)PositionGetDouble(POSITION_PROFIT);

         StringReplace(volume, ".", ",");
         StringReplace(open, ".", ",");
         StringReplace(sl, ".", ",");
         StringReplace(tp, ".", ",");
         StringReplace(pricecurrent, ".", ",");
         StringReplace(swap, ".", ",");
         StringReplace(profit, ".", ",");

         FileWriteString(hp, symbol+";"+extid+";"+comment+";"+(string)ticket+";"+(string)time+";"+(string)timemsc+";"+(string)timeupdate+";"+(string)timeupdatemsc+";"+(string)type+";"+(string)magic+";"+(string)identifier+";"+(string)reason+";"+volume+";"+open+";"+sl+";"+tp+";"+pricecurrent+";"+swap+";"+profit+"\r\n");

        }
      FileClose(hp);
     }
  }

//+------------------------------------------------------------------+

Lesen Sie bitte die Anleitung durch, dann löschen Sie diesen Text und geben Sie die Beschreibung Ihres Skriptes ein.
Anforderungen zum Thema, Umfang und der Gestaltung des Textes:

Welche Ideen enthält der Code und wie können Indikatorenwerte interpretiert werden? Beschreiben Sie externe Variablen. Wenn Sie einen Expert Advisor veröffentlichen, ist es empfehlenswert, das Symbol und den Zeitrahmen anzugeben. Wenn Sie eine Include-Datei (#include) veröffetnlichen, ist der Zweck der Datei anzugeben (für Trailung, für die Berechnung der Größe der eröffneten Position usw.)

Bilder müssen klein sein und 750х500 Pixel nicht überschreiten. Die Charts mit Indikatoren oder grafischen Objekten müssen schwarz-weiß sein: schwarz-weiße Kerzen bzw. schwarze Balken auf einem weißen Hintergrund. So kann man das Bild direkt vom Bildschirm ausdrucken.

Der Codes muss auf Englisch benannt und mit lateinischen Buchstaben (Buchstaben des englischen Alphabets) geschrieben werden. Z.B., nicht issledovanie.mq5, sondern research.mq5.

Hinweise:
  • Geben Sie dem Thema einen sinnvollen Namen und schreiben Sie eine kurze Beschreibung dazu.
  • Erklären Sie kurz den Code, um den Lesern das Verständnis zu erleichtern.
  • Fügen Sie Bilder hinzu, wo es möglich ist.
Wilson Relative Price Channel - mod Wilson Relative Price Channel - mod

Wilson Relative Price Channel - modifiziert

Laguerre RSI - no gamma Laguerre RSI - no gamma

Laguerre RSI - ohne Verwendung des gamma-Parameters

Accumulation/Distribution Accumulation/Distribution

Der Accumulation/Distribution Indikator wird aus Änderung von Preis und Volumen bestimmt.

Accelerator Oszillator (AC) Accelerator Oszillator (AC)

Der Acceleration/Deceleration Indikator (AC) misst die Beschleunigung und Verlangsamung des aktuellen Marktimpulses, der Kraft der Kursbewegung.