fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Sparrow
    S
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 9
    • Best 2
    • Controversial 0
    • Groups 0

    Sparrow

    @Sparrow

    2
    Reputation
    54
    Profile views
    9
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Sparrow Unfollow Follow

    Best posts made by Sparrow

    • RE: Importing MT5 example indicator RSI.mq5 is failing

      Also realized that data type "variable" was inserted and corrected this. Still had problems.

      Seems like the message string, i.e. the PrintFormat() argument, confuses the parser.

      Weird that importing a standard MT5 example custom indicator is so hard.

      Anyway, I got used to that but figure that many noobs - like I was - struggle with that. Might not be so good for the reputation of fxDreema. The graphical coding UI for MT5 that I love.

      posted in Bug Reports
      S
      Sparrow
    • Wrong "Open Time" in "For each Closed Position" ...

      ... when writing to file.

      0a640a78-d2f9-4539-9206-aa6db3ca33a0-image.png

      656a1943-38bf-42f9-a552-310ca313d801-image.png

      posted in Bug Reports
      S
      Sparrow

    Latest posts made by Sparrow

    • RE: Block logic "Indicator moves within limits"

      Many thanks! All is working now. Including "Indicator moves within limits".

      posted in Bug Reports
      S
      Sparrow
    • RE: Wrong "Open Time" in "For each Closed Position" ...

      Many thanks, @fxDreema. All tested and working well now. Including the profit calculation including swap and commission.

      Super happy also with your explanations. When a master explains the issues, everything appears more structured.

      fxDreema = premium product, service and support!

      🙏❤

      posted in Bug Reports
      S
      Sparrow
    • RE: Wrong "Open Time" in "For each Closed Position" ...

      ADDENDUM regarding WORKAROUND TWO:

      Problem was: How to get a list of deals for a position in MQL5. There is a function HistorySelectByPosition() but no simple way to get a position ID (PID). What a mess this is in MQL5! The same thing is so easy in MQL4.

      After extensive search I found only one resource explaining how to obtain a PID and where it comes from.

      Writing A Simple Script In Mql4 Is Not So Simple In Mql5
      https://www.youtube.com/watch?v=pPcjKLNZL88
      https://youtu.be/pPcjKLNZL88?t=2244 (with time code)
      by Jimdandy1958

      BTW, I even joined Patreon to thank Jim for this one. Big thanks!!

      Anyhow, Not so easy to get a singular open time for a (eventually) closed position. Could have a couple of partial closes in between, for example. Which time counts?

      In MT4, the “order history” (position history in MT5) splits each partial close in a separate position, which is nice and easy. In MT5, we have to program that ourselves. Have fun, admin, making open and close time work. I am working on my workaround function for writing a "position history" (MT5 speak) to a CSV file.

      PS: I am still hoping, there is something I missed and there is an elegant way to achieve this (o:

      posted in Bug Reports
      S
      Sparrow
    • RE: Wrong "Open Time" in "For each Closed Position" ...

      WORKAROUND attempt:

      Idea: At position open, save the time in a hash map (ticketNumber, openTime). Later, after the end of a backtest, access openTime from the hash map and write it to the file instead of the erroneous value from the loop “For each Closed Position”.

      See the source code of a function that acts like an object managing a hash map below. Added this to the functions area of Custom Blocks. This part of the workaround is tested and working well.

      HOWEVER: I learned something new. Something, that disabled this workaround completely: In MT5, we have different “ticket numbers” for deals, orders and positions. Specifically, the ticket number I can access directly after position open is not the same as the one in the loop “For each Closed Position”. I didn’t find any way to map those two ticket numbers with the fxDreema UI. If you know a way, please share.

      Therefore, WORKAROUND TWO is this: Develop an independent function writing the complete CSV-file with the position history and call it in “on Deinit”.

      A fix of the bug described above would be appreciated.

      Here is the code on the function managing a hash map. You may like to modify its hash and value types according to your needs. Furthermore, at the moment, the “action” parameter is not used. It’s a template for all kinds of hash maps. Use a copy of this function with different name for each hash map that you need.

      double hashMap(int hash=-1, double value=-1, string action=NULL)
      /*
       * This is a template for a function acting as a simple object
       * managing a hash map. For usage as custom code in fxDreema, for
       * example. Copy this function for each hashMap that you need, rename
       * it according to the content and adapt the types of hash and value
       * as desired.
       *
       * In this template, the hash values must be numbers >= 0 (!)
       *
       * Returns (a) 0 if all went well, or (b) the requested value belonging
       * to a hash key, or (c) -1 in case of an error or "hash key not found".
       */
        {
         static int hashArray[];
         static double valueArray[];
         static const int RESERVE_SIZE=3000;
      
      //
      // Action "return map size"
      //
      
         if(hash==-1 && value==-1 && action==NULL)
            return(ArraySize(hashArray));
      
      //
      // Action "add element"
      //
      
         if(hash>-1 && value>-1 && action==NULL)
           {
            int i;
            int size=ArraySize(hashArray);
            for(i=0; i<size; i++)
               if(hashArray[i]==hash)
                  break;
            if(i<size)  // Found => Invalid
              {
               PrintFormat(">>>>> Error in %s(): hash=%i existing.",__FUNCSIG__,hash);
               return(-1);
              }
            int newSize=ArraySize(hashArray)+1;
            ArrayResize(hashArray,newSize,RESERVE_SIZE);
            ArrayResize(valueArray,newSize,RESERVE_SIZE);
            hashArray[newSize-1]=hash;
            valueArray[newSize-1]=value;
            return(0);
           }
      
      //
      // Action "get element"
      //
      
         if(hash>-1 && value==-1 && action==NULL)
           {
            int i;
            int size=ArraySize(hashArray);
            for(i=0; i<size; i++)
               if(hashArray[i]==hash)
                  break;
            if(i<size)  // Found
               return(valueArray[i]);
            else  // Not found
               return(-1);
           }
      
      //
      // Action "unidentified"
      //
      
         return(-1);
        }
      
      posted in Bug Reports
      S
      Sparrow
    • RE: Wrong "Open Time" in "For each Closed Position" ...

      ADDENDUM: The time that is writen as Open Time of the trade (always the same) is the account open time. The fix might be quick and easy.

      posted in Bug Reports
      S
      Sparrow
    • RE: Wrong "Open Time" in "For each Closed Position" ...

      Here is an easy way to reproduce this error:

      Compile this shared project:
      https://fxdreema.com/shared/FhPzvdene

      Pull the EA "Issue Writing Open Time" into the chart of an MT5-instance that has a history of trades.

      The output file with the erroneous "Open Time" is written to folder \MQL5\Files.

      posted in Bug Reports
      S
      Sparrow
    • RE: Importing MT5 example indicator RSI.mq5 is failing

      Also realized that data type "variable" was inserted and corrected this. Still had problems.

      Seems like the message string, i.e. the PrintFormat() argument, confuses the parser.

      Weird that importing a standard MT5 example custom indicator is so hard.

      Anyway, I got used to that but figure that many noobs - like I was - struggle with that. Might not be so good for the reputation of fxDreema. The graphical coding UI for MT5 that I love.

      posted in Bug Reports
      S
      Sparrow
    • RE: Block logic "Indicator moves within limits"

      Many thanks, @l-andorrĂ  for your suggestions,

      The reason are changes in indicator values less than a pip fraction. This can happen in any timeframe depending on the indicator calculation logic. Woudln't it be better to NOT normalize double values so that coparisons are exact no matter what?

      posted in Bug Reports
      S
      Sparrow
    • Wrong "Open Time" in "For each Closed Position" ...

      ... when writing to file.

      0a640a78-d2f9-4539-9206-aa6db3ca33a0-image.png

      656a1943-38bf-42f9-a552-310ca313d801-image.png

      posted in Bug Reports
      S
      Sparrow