Problem with the number of positions

Take a look at this photo

We sell about 5 candles, but Expert also sells the next 5 candles.
When the sales signal is issued, this code covers 10 candles after the sales signal.
Even when the sales signal runs out
I would even get 4 if we put 10 candles in the box (MathMax(10,Orders())) if the sales signal was 4 and didn't reach 10.

```//+------------------------------------------------------------------+
string Hama()
{
double b1_shift1=iCustom(Symbol(),240,"HamaSystem",0,1);
double b1_shift2=iCustom(Symbol(),240,"HamaSystem",1,1);
double b1_shift3=iCustom(Symbol(),240,"HamaSystem",2,1);
double b1_shift4=iCustom(Symbol(),240,"HamaSystem",3,1);
double b1_shift5=iCustom(Symbol(),240,"HamaSystem",4,1);
double b1_shift6=iCustom(Symbol(),240,"HamaSystem",5,1);

double b2_shift1=iCustom(Symbol(),240,"HamaSystem",0,2);
double b2_shift2=iCustom(Symbol(),240,"HamaSystem",1,2);
double b2_shift3=iCustom(Symbol(),240,"HamaSystem",2,2);
double b2_shift4=iCustom(Symbol(),240,"HamaSystem",3,2);
double b2_shift5=iCustom(Symbol(),240,"HamaSystem",4,2);
double b2_shift6=iCustom(Symbol(),240,"HamaSystem",5,2);

{
if (b1_shift1<b2_shift1 && b1_shift2>b2_shift2)

{
TimeOfSellSignal = 0;
}

if (b1_shift1>b2_shift1 && b1_shift2<b2_shift2)

{
if (TimeOfSellSignal==0)
TimeOfSellSignal = iTime(Symbol(),240,1);
}
if (TimeOfSellSignal>0 &&
iBarShift(Symbol(),240,TimeOfSellSignal)<=MathMax(10,Orders()))
return("sell");
}

return(0);
}
//+------------------------------------------------------------------+```

Naqibjan:

Take a look at this photo

We sell about 5 candles, but Expert also sells the next 5 candles.
When the sales signal is issued, this code covers 10 candles after the sales signal.
Even when the sales signal runs out
I would even get 4 if we put 10 candles in the box (MathMax(10,Orders())) if the sales signal was 4 and didn't reach 10.

Here's my 'guess' this time round (sorry, I just have to guess, because your questions are always difficult to understand):

```  if (b1_shift1<b2_shift1 && b1_shift2>b2_shift2)
{