fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Custom logic block implementation.

    Questions & Answers
    2
    5
    758
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      coinmaster last edited by coinmaster

      Hello.
      I am trying to implement a custom logic block that writes data into a file for each pass of the optimization.
      The normal write to file logic block does not use use the frame() function and therefore cannot write to file during optimization.

      I paid someone to cook a bit of code up for me that will do this.
      The code below will write the bid price to file as a test, however the intent is to replicate the 'write to file' logic block and select a list of variables to input.

      But for now I'm taking it one step at a time and I'm only trying to insert this test script as the logic block. However I can't seem to get it to work.

      I placed everything beneath OnTick() into the logic block editor of https://fxdreema.com/studio/MQL5
      I placed the OnTesterPass() and OnTesterInit() code into the custom functions section
      and everything above OnTick into global variables.

      This did not compile.

      So I placed a few of the global variables into the logic block until it compiled without errors.
      However the function does not activate when I place the logic block onto the 'every bar' timer.

      Can anyone inform me of my error?

      0_1629042201793_905218eb-c3c5-4a85-953a-4c621a0b1b75-image.png

      0_1629042330295_dd70f7dc-6ff7-4cd9-a261-b69ca1333070-image.png

      0_1629042350939_83f0f183-a987-4cfa-8504-ebb21d2d9aae-image.png

      #property copyright "Copyright 2020, IVZ."
      #property link "https://www.mql5.com/ru/users/febintegral/"
      #property version "1.00"
      #property tester_everytick_calculate

      double stat_values[7]; // Массив для показателей теста
      int cnt = 0;
      input double test = 1;
      //+------------------------------------------------------------------+
      //| |
      //+------------------------------------------------------------------+
      class SomeData
      {
      public:
      string store;
      };

      SomeData pSomeDAta[1];
      bool Executed = false;
      //+------------------------------------------------------------------+
      //| |
      //+------------------------------------------------------------------+
      void OnTick()
      {

      double bidPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Getting the Bid Price

      double Mass[20];
      for(int i =0; i < 17; i++)
      Mass[i] = i;

      MqlDateTime mdt;
      TimeToStruct(TimeCurrent(),mdt);
      string output = IntegerToString(mdt.year) + "." + IntegerToString(mdt.mon) + "." + IntegerToString(mdt.day) + "_" + IntegerToString(mdt.hour) + ":" + IntegerToString(mdt.min) + ":" + IntegerToString(mdt.sec)+ ";" + DoubleToString(bidPrice) + ";";

      for(int i =0; i < 17; i++)
      output += "SomeData_" + DoubleToString(Mass[i]) + ";";

      pSomeDAta[0].store += output + "\r\n";

      datetime dt = TimeCurrent();
      MqlDateTime mdt1,mdt2;
      TimeToStruct(dt,mdt2);

      TimeCurrent(mdt1);

      int PassNumber = 0;
      if(mdt.hour == 23 && mdt.min >= 50 && Executed == false)
      {

        string file_name;
        long search_handle=FileFindFirst("*.csv",file_name,FILE_COMMON);
        //--- проверим, успешно ли отработала функция FileFindFirst()
        if(search_handle!=INVALID_HANDLE && -1 != StringFind(file_name,"filetest",0))
          {
           int abc= 0;
           //--- в цикле проверим являются ли переданные строки именами файлов или директорий
           do
             {
              abc++;
             }
           while(FileFindNext(search_handle,file_name));
      
      
           string sep="_";                // A separator as a character
           ushort u_sep;                  // The code of the separator character
           string result[];               // An array to get strings
           //--- Get the separator code
           u_sep=StringGetCharacter(sep,0);
           //--- Split the string to substrings
           int k = StringSplit(file_name,u_sep,result);
      
           PassNumber = (int)StringToInteger(result[1]);
           PassNumber++;
           //--- закрываем хэндл поиска
           FileFindClose(search_handle);
          }
      
      
      
        string headers="Header_1;Header_2;Header_3;Header_4;Header_5;Header_6;Header_7;Header_8;Header_9;Header_10;Header_11;Header_12;Header_13;Header_14;Header_15;Header_16;Header_17;Header_18;Header_19";
        int h2=FileOpen("filetest_" + IntegerToString(PassNumber) + "_.csv",FILE_READ|FILE_WRITE|FILE_SHARE_WRITE|FILE_CSV|FILE_COMMON);
      
        FileSeek(h2,0,SEEK_END);
        FileWrite(h2,headers);
      
        FileSeek(h2,0,SEEK_END);
        FileWrite(h2,pSomeDAta[0].store);
      
        FileClose(h2);
        Executed = true;
      
       }
      

      cnt++;

      }

      Website doesn't fit all the code into the box for some reason. I attached file.0_1629040410511_FramesAndFiles (1).mq5

      C 1 Reply Last reply Reply Quote 1
      • C
        coinmaster @coinmaster last edited by

        It seems that the OnTester() and OnTesterPass() sections are not compiling into the code.
        A search for OnTester() or OnTesterPass() in the source file does not reveal any results.

        Could this be a bug?

        l'andorrà 1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà @coinmaster last edited by

          @coinmaster I'm not a programmer but I know MQ% is not as well developed in fxDreema as MQ4. I would recommend to contact the admin and aski him.

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          1 Reply Last reply Reply Quote 0
          • C
            coinmaster last edited by

            He's rarely online anymore sadly. But I sent him a message.

            l'andorrà 1 Reply Last reply Reply Quote 0
            • l'andorrà
              l'andorrà @coinmaster last edited by

              @coinmaster True. However, I can guarantee he replied all personal messages. He may take its time to do it, though.

              (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

              (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

              (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              Online Users

              M
              K
              S
              F
              B
              T
              E

              32
              Online

              146.6k
              Users

              22.4k
              Topics

              122.6k
              Posts

              Powered by NodeBB Forums | Contributors