English

## Max per Box

 4 FxTrading8565 2016.06.21 13:10   Hello Coders ,This is my first time here on this forum . I needed a little bit help and suggestion from u awesome guys. I am unable to solve this puzzle that how can i set max number of trades . I know that is easy but here a situation is a little bit different . I want to set max number of trades per box . I found an indicator which draws boxes on the screen so i want to set limited number of trades to be placed on the box period . Here is the pic of the  indicator . Hope so that u know the solution for the situation .
13118
WHRoeder 2016.06.21 14:02 #

 FxTrading8565: . Hope so that u know the solution for the situation. You know when the current box starts, count the orders opened after that time.learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.

 Moderator3206 angevoyageur 2016.06.21 15:15 #   FxTrading8565:... indicator . Hope so that u know the solution for the situation .                                                                                         Yes, it just need to be coded, nothing really difficult.
 4 FxTrading8565 2016.06.21 18:51 #   angevoyageur: Yes, it just need to be coded, nothing really difficult.I will be very thank full if u give me its basic skeleton example
 Moderator3206 angevoyageur 2016.06.21 19:35 #   FxTrading8565: I will be very thank full if u give me its basic skeleton exampleWhat have you tried ?
 4 FxTrading8565 2016.06.21 19:55 #   angevoyageur: What have you tried ?here is my attempt ...I am trying to count closed position after there is a new box ....```if( box_start != last_box )     // if there is a new box { last_box = box_start ;   start_box = iTime(NULL,0,0);  // start time of the box } static datetime loct; // last order closed time for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--) if (OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY)      &&  OrderType()        <=1    &&  OrderCloseTime()    >  loct && OrderCloseTime() > start_box    )    {     count_orders ++ ;   // counting the number of trades     loct = OrderCloseTime() ;     break;    } // user define function for checking the number of trades that have been counted bool place_orders() {       if( count_orders < 4 )   return(true);   else if( count_orders > 4 )   return(false);   else   return(EMPTY_VALUE);   } ```
 13118 WHRoeder 2016.06.22 13:48 #   `   &&  OrderCloseTime()    >  loct && OrderCloseTime() > start_box`You want to count how many were opened during the box. Why are you looking for the last closed order?```bool place_orders() {       if( count_orders < 4 )   return(true);   else if( count_orders > 4 )   return(false);   else   return(EMPTY_VALUE);   } ```Bool only has true or false. You can't return EMPTY_VALUE