fxDreema

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

    'attrTicketChild' - function not defined; Check profit (money) doesn't work as intended

    Bug Reports
    4
    6
    1962
    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.
    • Abade69
      Abade69 last edited by

      A new error that appears only in one of my EA's:

      [0_1521740864590_14.png]

      Check profit (money) will take profit at random quantities.

      1 Reply Last reply Reply Quote 0
      • Abade69
        Abade69 last edited by

        Found out the money TP calculation works, but it won't take commisions into account.

        1 Reply Last reply Reply Quote 0
        • A
          azazelio last edited by

          Hi there

          I got the same error attrTicketChild.

          I fixed changing these 2 lines:
          || (ClosePartialMode == 1 /*&& e_attrTicket() == attrTicketParent(e_attrTicket()) /&& e_attrTicket() == attrTicketChild(e_attrTicket())) // fully closed
          || (ClosePartialMode == 2 /
          && e_attrTicket() == attrTicketParent(e_attrTicket()) */&& e_attrTicket() != attrTicketChild(e_attrTicket())) // partially closed

          to these 2:
          || (ClosePartialMode == 1 && e_attrTicket() == attrTicketParent(e_attrTicket()) && e_attrTicket() == attrTicketChild(e_attrTicket())) // fully closed
          || (ClosePartialMode == 2 && e_attrTicket() == attrTicketParent(e_attrTicket()) && e_attrTicket() != attrTicketChild(e_attrTicket())) // partially closed

          And adding the function between attrTicket() and attrTicketParent()

          int attrTicketChild(int ticket)
          {
          int pos, total, retval=0;

          if (!OrderSelect(ticket,SELECT_BY_TICKET)) {retval=ticket;}

          /*
          //-- check if trade is added to volume ----------------------------
          if (retval==0) {
          int p_pos=StringFind(attrComment(), "[p=");
          if (p_pos >= 0) {
          string ptag=StringSubstr(attrComment(),p_pos);
          ptag=StringSubstr(ptag,0,StringFind(ptag,"]")+1);
          retval=StrToInteger(StringSubstr(ptag,3,-1));
          }
          }
          */
          double OP = 0;
          datetime OT = 0;
          string S = "";
          int M = 0;
          int T = 0;
          double L = 0;
          int D = 0;

          //-- check if trade is partially closed (in trades) ---------------
          if (retval==0) {
          OP = OrderOpenPrice();
          OT = OrderOpenTime();
          S = OrderSymbol();
          M = OrderMagicNumber();
          T = OrderType();
          L = OrderLots();
          D = (int)MarketInfo(S,MODE_DIGITS);

          total=OrdersTotal();
          for (pos=total-1; pos>=0; pos--) {
          if (OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
          {
          if (OrderOpenTime()<OT) {
          break;
          }
          if (
          OrderTicket()!=ticket
          && (OrderSymbol()==S)
          && (OrderMagicNumber()==M)
          && (OrderType()==T)
          && (NormalizeDouble(OrderOpenPrice(),D)==NormalizeDouble(OP,D))
          && (OrderOpenTime()==OT)
          )
          {
          retval=OrderTicket();
          break;
          }
          }
          }
          }
          //-- still nothing found - search in history trades now -----------
          if (retval==0) {
          total=OrdersHistoryTotal();
          for (pos=total-1; pos>=0; pos--) {
          if (OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY))
          {
          if (OrderOpenTime()<OT) {
          break;
          }
          if (
          OrderTicket()!=ticket
          && (OrderSymbol()==S)
          && (OrderMagicNumber()==M)
          && (OrderType()==T)
          && (NormalizeDouble(OrderOpenPrice(),D)==NormalizeDouble(OP,D))
          && (OrderOpenTime()==OT)
          )
          {
          retval=OrderTicket();
          break;
          }
          }
          }
          }

          if (retval<ticket) {retval=0;}

          if (!OrderSelect(ticket,SELECT_BY_TICKET)) {return ticket;}
          if (retval>0) {
          return(retval);
          }
          else {
          return(ticket);
          }
          }

          After that, you can compile with no problems.
          Hope that helps

          Thanks

          Abade69 1 Reply Last reply Reply Quote 1
          • Abade69
            Abade69 @azazelio last edited by

            @azazelio Thanks for your reply 🙂

            Error stopped appearing after removing "On_Trade events".

            1 Reply Last reply Reply Quote 0
            • D
              David197 last edited by

              Hello,

              The same issue It's happening to me as well...

              S 1 Reply Last reply Reply Quote 1
              • S
                SydneyFox @David197 last edited by

                I'm having this issue today as well!!!

                @fxDreema why are we continually having these sort of issues?

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

                Online Users

                A
                M
                M
                E
                C
                M
                F
                L
                F
                F
                E
                K

                30
                Online

                146.6k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors