Ordertype based on indicator - page 3

 
if(check == true)
{
   down= down = iCustom(NULL,0,"ASCTrend1sig_noSound", RISK, CountBars,1,0);
   up= down = iCustom(NULL,0,"ASCTrend1sig_noSound", RISK, CountBars,0,0);
}//if(checkforTrade == true) 


if(OrdersTotal() == 0 && check == true)
{
   if(down!= 0.0 && opentrade ==false)
   {
      opensell();
      check=false;
      opentrade=true;
   }// if(downtrend!=EMPTY_VALUE)
                
   else if(up!=0.0 && opentrade ==false)
   {
      openbuy();
      check=false;
      opentrade=true;
   }// else(uptrend!=EMPTY_VALUE)
    
    
  }// if(OrdersTotal()==0)

 
 
albo111:  After one order is closed it opens another order with the same signal and thats what I doesent want
if(down!= 0.0 && ...
So stop looking at a level (down != 0) and start looking for a change of signal
static double down; // Or global.

bool signal_prev = down != 0;
down = iCustom(NULL,0,"ASCTrend",1,0);
if(down != 0.0 && !signal_prev && ...

Reason: