Count orders

 

Hi all,

Sorry for the silly question;

I'm looking for increase lots based on the number of open orders. For that am make use of the follow code, but seems to not work. 

 for(Total = 1; Total <= OrdersTotal(); Total++) 
   
    Lots = MathRound(AccountBalance()/100)/1000;
    lots = MathPow(2,Total)*Lots;

Could you clarify what is wrong with my approach to get that ?

Thank you in advance for any support provided.

Luis 

 
  1. Format properly.
     for(Total = 1; Total <= OrdersTotal(); Total++) 
        Lots = MathRound(AccountBalance()/100)/1000;
    
      lots = MathPow(2,Total)*Lots;
     for(Total = 1; Total <= OrdersTotal(); Total++){
        Lots = MathRound(AccountBalance()/100)/1000;
     }
      lots = MathPow(2,Total)*Lots;

  2. Lots = MathRound(AccountBalance()/100)/1000;
    Why do you have this in a loop? Nothing is changing?
  3. lots = MathPow(2,Total)*Lots;
    What is the value of Total after the loop?
  4. what is the value of Lots after the loop when you have no open orders?
  5. There are no mind readers here. "But seems to not work," tells us NOTHING.
 
WHRoeder:
  1. Format properly.

  2. Why do you have this in a loop? Nothing is changing?
  3. What is the value of Total after the loop?
  4. what is the value of Lots after the loop when you have no open orders?
  5. There are no mind readers here. "But seems to not work," tells us NOTHING.


Hi WHRoeder,

Thank you for your time. 

Have seen this piece of code

double Lots = MathRound(AccountBalance()/100)/1000;
  
  if((H-Bid>Limit*Point))
    {OrderSend(Symbol(),OP_BUY,Lots,Ask,1,0,0,"",MAGICMA,0,CLR_NONE);
     for(int i=1; i<5; i++){OrderSend(Symbol(),OP_BUYLIMIT,MathPow(2,i)*Lots,Ask-i*Grid*Point,1,0,0,"",MAGICMA,0,CLR_NONE);}

  where for every pending order an increase of lot is achieved using ;  

for(int i=1; i<5; i++)

 I though to use the same approach to get a lot increase for every new order that will open.

Regarding Total the way I'm seen will increase by 1 every time a new order opens, I mean, if I start Total with 1 the order should open with say, 0.10, then when condition comes to open a second order Total will be 2 and so on.

On Comment I see that Total is 1 at first, but it do not goes up. And I'm stucked at this point.

If I do not make use of this code the EA is working as expected so I believe that the rest of code as nothing to do with this issue. Nevertheless in attach is the EA code.

Once again I appreciate your support to put me on the right way.

Luis 

 
luisnevesOnce again I appreciate your support to put me on the right way.
I asked FIVE questions. You answered just one:
Regarding Total the way I'm seen will increase by 1 every time a new order opens, I mean, if I start Total with 1 the order should open with say, 0.10, then when condition comes to open a second order Total will be 2 and so on.
so why didn't you code it that way? No loop required.
Total = OrdersTotal() + 1;
 
WHRoeder:
I asked FIVE questions. You answered just one:so why didn't you code it that way? No loop required.


Hi WHRoeder,

One of these days have to pay you a dinner just for your patience...

Even with your last advice am not get it to work...

Very sorry for the time am taking from you. Need to go study this stuff better.

Nevertheless thank you for time spent.

Best regards

Luis 

Update !!

It's working now !

Thank you again

Luis 

Reason: