Download MetaTrader 5
To add comments, please log in or register
Do you wonder how to use widgets? Read the article!
all-four-inches 2014.12.31 09:08 

Hi guys,

 I'm trying to learn some mql4 coding to create my own EA's and im going through the online thing they have here and i am a bit confused on the following parts:

    Symb=Symbol();                               // Security name

   Total=0;                                     // Amount of orders
   for(int i=1; i>=OrdersTotal(); i++)          // Loop through orders
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is the next one
        {                                       // Analyzing orders:
         if (OrderSymbol()!=Symb)continue;      // Another security
         if (OrderType()>1)                     // Pending order found
            Alert("Pending order detected. EA doesn't work.");
            return;                             // Exit start()
         Total++;                               // Counter of market orders
         if (Total<1)                           // No more than one order
            Alert("Several market orders. EA doesn't work.");
            return;                             // Exit start()


why is it "if (Total < 1)" and not "Total > 1" ??? it doesnt make sense to me :S arent we looking for total to be higher than 1? not less than?


also further down:

    Alert("Attempt to open Buy. Waiting for response..");

         Ticket=OrderSend(Symb,OP_BUY,Lts,Ask,2,SL,TP);//Opening Buy

         if (Ticket < 0)                        // Success :)


            Alert ("Opened order Buy ",Ticket);


 why is it "Ticket < 1" and not "Ticket > 1" ??? wouldnt a ticket number coming back be much larger than 1?

 Am i completely misreading something here?

any help would be much appreciated :^) 

To add comments, please log in or register