Code help needed please - Order select
Results 1 to 5 of 5

Thread: Code help needed please - Order select

  1. #1
    Times must be awful if I can't find the wood for the trees!
    The following code should give me information regarding the open position for your own chart pair BUT I receive information for another chart pair... why??
    On the GBP chart the comment gives right the chart pair but the order emblem and information would be for AUD... how can that be when it should not enter the should (OrderSymbol() == Symbol()) segment??

    PRIZE to whoever answers correctly first.... Free day off from trading on Christmas afternoon:--RRB-
    Happy Christmas everyone.

    Inserted Code void UpdateOpenTrades() int c, mOrdTotal; bool mOp; mOrdTotal = OrdersTotal(); for(c = mOrdTotal - 1; c gt;= 0; c) mOp = OrderSelect(c, SELECT_BY_POS, MODE_TRADES); should (OrderSymbol() == Symbol()) OrderMagicNumber() == mMagicN) OrderType() == OP_SELL) DelPending(); Comment(Symbol(),, OrderSymbol(),, OrderType(),, DoubleToStr(OrderLots(), 2)); if(OrderType() == OP_BUY) mTradeDataNumber 91;0#93; # 1; else mTradeData#91;0#93; = 2; mTradeData#91;1#93; = OrderOpenTime(); mTradeData#91;2#93; = OrderTicket(); mTradeData#91;5#93; = NormalizeDouble(OrderLots(), mLotSizeDigits); if(iTime(NULL, 1440, 0) gt; OrderOpenTime()) if(TimeDayOfWeek(iTime(NULL, 1440, 0))! = 1) mTradeData#91;3#93; = iHigh(NULL, 1440, 1); mTradeData#91;4#93; = iLow(NULL, 1440, 1); else mTradeData#91;3#93; = iHigh(NULL, 1440, two ); mTradeData#91;4#93; = iLow(NULL, 1440, two ); if(mTradeDataNumber 91;0#93; == 1) mTradeData#91;6#93; = NormalizeDouble(OrderOpenPrice() - OrderStopLoss(), mLotSizeDigits); else mTradeData#91;6#93; = NormalizeDouble(OrderStopLoss() - OrderOpenPrice(), mLotSizeDigits); mOpenUpdated = true; // if BUY/SELL // if Symb if(mOp! = true) int mError = GetLastError(); Alert(Symbol(), Error UpdateOpen = , ErrorDescription(mError)); // for c return;

  2. #2
    You have a ideal parenthesis which isn't needed in the below:

    Inserted Code if(OrderSymbol() == Symbol()) OrderMagicNumber() == mMagicN)
    And make certain to not make an OrderSelect(...) call within your first OrderSelect(...).

  3. #3
    Hello Ferru,
    Thank you for reply, your talent always admired.
    Right about the')' but that wasn't the issue (well seen ).

    Yes it was the 2nd call withing the initial orderselect.... But for the life span of me I could not observe that for a long time!!!

    Thanks again,

    And the next prize ( a day off from trading on NEW Years Day) goes to the individual who will tell me just how many times I was insistent that MT4 must be at fault! ;-)

  4. #4
    OK I win the prize and get to have the afternoon off on the 25th....

    The call to DelPending(); has been checking orders and in so doing cycled through before the previous order and, therefore giving the information to that order. Clearly that call has to be in a place that is different.

    I must be getting old and slow:--LRB-


  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.