Orders not passing

 

Hi,

I am experiencing some strange problems with my expert advisor.

bool hasbought = false;
bool hassold = false;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   return(0);
  }
//+------------------------------------------------------------------+
//| Stochastic oscillator                                            |
//+------------------------------------------------------------------+
int start()
{

double kingnow;
double kingprevious;
//int test1, test2;

kingnow = iStochastic(NULL,0,14,5,3,0,0,MODE_MAIN,1);
kingprevious = iStochastic(NULL,0,14,5,3,0,0,MODE_MAIN,2);


if (kingnow<20 && kingnow>kingprevious && hasbought == false)
{OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0.98*Ask,1.03*Bid,"AutoBuy",0,0,Green);
hasbought = true;
hassold = false;
}


if (kingnow>80 && kingnow<kingprevious && hassold == false)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0.98*Bid,1.03*Ask,"AutoSell",0,0,Red);
hassold = true;
hasbought = false;
 }
 
// the sell seems to be a good indicator but is never used!
 
   return(0);

}

As you can see it is very basic but:

No sell order is ever filed and just some buy orders are. I don't understand why. Globally speaking my EA's seem to miss some signals I programmed them to trigger on because some orders are that should be triggered are not.

Thanks for your help!
 
Arminius :

Hi,

I am experiencing some strange problems with my expert advisor.

As you can see it is very basic but:

No sell order is ever filed and just some buy orders are. I don't understand why. Globally speaking my EA's seem to miss some signals I programmed them to trigger on because some orders are that should be triggered are not.

What are Function return values ? How do I use them ? - MQL4 forum

Can you place the stoploss of a sell trade lower then Takeprofit level of that same trade ???


 
Oh... indeed, stupid copy/pasting. If I correct this it fixes the problem. Sorry for the stupidity of the mistake.
Reason: