Max per Box

 

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 .                                                                                        


 
FxTrading8565: . Hope so that u know the solution for the situation.
  1. You know when the current box starts, count the orders opened after that time.
  2. 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.
 
FxTrading8565:
...

 indicator . Hope so that u know the solution for the situation .                                                                                        


Yes, it just need to be coded, nothing really difficult.
 
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
 
FxTrading8565:
I will be very thank full if u give me its basic skeleton example
What have you tried ?
 
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);  
} 

 
  1.    &&  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?
  2. 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