OrderSelect function question - page 2

 
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void CheckForClose()
  {
   double ma;
//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
//--- get Moving Average 
   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//---
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      //--- check order type 
      if(OrderType()==OP_BUY)
        {
         if(Open[1]>ma && Close[1]<ma)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
      if(OrderType()==OP_SELL)
        {
         if(Open[1]<ma && Close[1]>ma)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
     }
//---
  }
for(int i=0;i<OrdersTotal();i++)
 

A new type of art.

Trading satire.

I love it.

 
boopa26:

1. does not need c knowledge. mql4 is different functions

boopa26 does not waste peoples time

  1. You think you can write code without knowing how to write code. Functions are irrelevant.
    boopa26: wants to write order select function to close orders without for cycles or while cycles.
    Then why did you just post code that does use loops? You are wasting our time.
  2. In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
 
for(last_index_inside_trade_pool=OrdersTotal()-1;last_index_inside_trade_pool>=0;last_index_inside_trade_pool--)

   {if(OrderSelect(last_index_inside_trade_pool,SELECT_BY_POS,MODE_TRADES)==1&&
       OrderMagicNumber()==magic_number&&
       OrderType()==OP_SELL)

       OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Red);


    if(OrderSelect(last_index_inside_trade_pool,SELECT_BY_POS,MODE_TRADES)==0)

       Print("OrderSelectError: ",GetLastError());}

wasting time huh? does the above code look like i am wasting your time? uh... probably no WHRoeder

this was no easy task but code above does close orders. does not understand though. would be nice if coder explains more details

what boopa26 thinks

static int last_index_inside_trade_pool = OrdersTotal()-1

while last_index_inside_trade_pool >=0 do code below. do last_index_inside_trade_pool--

code below finds order. checks order. closes order. does GetLastError()

does not understand though

if(OrderSelect(last_index_inside_trade_pool,SELECT_BY_POS,MODE_TRADES)==1&&
 
boopa26: wasting time huh? does the above code look like i am wasting your time?
Yes. I asked two questions and you totally ignored them.
 

Then why did you just post code that does use loops?

cycles code can be written different to do same without cycles. example

static int last_index_inside_trade_pool;
//below start()
last_index_inside_trade_pool=OrdersTotal()-1;

  if(OrdersTotal()>0&&
     iMA(NULL,0,1,0,MODE_SMMA,PRICE_CLOSE,1)>iMA(NULL,0,10,0,MODE_SMMA,PRICE_CLOSE,1)&&
     OrderSelect(last_index_inside_trade_pool,SELECT_BY_POS,MODE_TRADES)==1&&
     OrderMagicNumber()==99999&&
     OrderType()==OP_SELL)

    {last_index_inside_trade_pool--;
     OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Red);}

no loops but same result. boopa26 prefers if conditions to for cycles while cycles

You think you can write code without knowing how to write code. Functions are irrelevant.

i know how to do if conditions while cycles for cycles basic math. thats a good start WHRoeder. c programming is c programming. mql4 is mql4. WHY? because of FUNCTIONS. mql4 does do c programming example * () == etc but not same because of functions

 

what switches order select function from 0 to 1?

if(OrderSelect(last_index_inside_trade_pool,SELECT_BY_POS,MODE_TRADES))==1

does order select function switch from 0 to 1 after orders total is greater than zero?


documentation

"Returned value

It returns true if the function succeeds, otherwise falses. To get the error information, one has to call the GetLastError() function."

it returns 1 if the function succeeds?

 

I love this guy :-)

Are you writing only on this forum or have you other links?

If you are doing this on a stage, where can i by tickets?

 

just this forum

eddie do you know anything about order select function?

 
boopa26:

Then why did you just post code that does use loops?

cycles code can be written different to do same functions without cycles. example

no loops but same result. boopa26 prefers if conditions to for cycles while cycles

You think you can write code without knowing how to write code. Functions are irrelevant.

i know how to do if conditions while cycles for cycles basic math. thats a good start WHRoeder. c programming is c programming. mql4 is mql4. WHY? because of FUNCTIONS

And you wonder why your code still does not work? Because you still don't know the "basics", which had you followed "step 1" and learned to properly code in "C", you would have been much more adept at coding in MQL (because it is similar to C and C++)!

You even fail at understanding the "functions" (step 3)! Since when does "OrderSelect()" return and integer, when the documentation clearly states that it returns a Boolean? You don't even check the result of the "OrderClose()" or if an run-time error occurred in any part of your code!

Your Result: You ended up with "burnt charcoal" and since you refuse to take our advice, you also waste our time!

Reason: