EA taking a trade I don't uderstand

 

Can someone help me understand why my ea took the following trade?

Sell on July 1 @ 17:17 for 1.44657

My EA is telling it NOT to sell if the Stoch is going up.

Did I miss something? I have looked at this every way I can... going cross eyed.

This is on the 4 hour chart. I don't know how to include the screen shot or I would...

But suffice it to say, the Stoch is going up from the previous period. It still took the trade.

extern int bband.time = 9;
extern int bband.devi = 2;

extern double lot.size.1 = 0.01;




void open.trade()
{
      double upper.bband = iBands(NULL,0,bband.time ,bband.devi,0,PRICE_OPEN,MODE_UPPER,0);
      double   sma.bband = iMA   (NULL,0,bband.time,0,MODE_SMA,PRICE_OPEN,0);  
      double lower.bband = iBands(NULL,0,bband.time ,bband.devi,0,PRICE_OPEN,MODE_LOWER,0);
      double stoch.00.0  = iStochastic(NULL,0, 14,1,4,MODE_SMA,0,MODE_MAIN,0) ;
      double stoch.00.1  = iStochastic(NULL,0, 14,1,4,MODE_SMA,0,MODE_MAIN,1) ;

   int total_trades=OrdersTotal();
   if(total_trades > 0) return;
   

//  -------------------------- go long ------------------------------------------------------
if(
            80 > stoch.00.0  &&       //   .00.0 = time period = current chart    shift = 0
   upper.bband > Ask &&
    stoch.00.0 > stoch.00.1   
                                ){
int ticket2=OrderSend(Symbol(),OP_BUY,lot.size.1,Ask,3,0,0,script.2,255,0,CLR_NONE);}
//--------------------------------------------------------------------------------------------



//  -------------------------- go short ------------------------------------------------------
if(
              20 < stoch.00.0  &&       //   .00.0 = time period = current chart    shift = 0
     lower.bband < Bid &&
      stoch.00.0 < stoch.00.1   
                                ){
   int ticket=OrderSend(Symbol(),OP_SELL,lot.size.1,Bid,3,0,0,script.2,255,0,CLR_NONE);}
//--------------------------------------------------------------------------------------------

   if(ticket<1){
      int error=GetLastError();
      Comment("\n  Error = ",ErrorDescription(error));
      return;
               }

//----
return(0);
}
// ------- end -----  open trades ----------------------------------------------------------------+
//================================================================================================
 
mrchuckw:
Can someone help me understand why my ea took the following trade? Did I miss something? I have looked at this every way I can... going cross eyed. the Stoch is going up from the previous period. It still took the trade.

I don't know how to include the screen shot or I would...
  1. Nothing obvious, can't tell about stoch since no screen shot.

  2. int total_trades=OrdersTotal();
    if(total_trades > 0) return;
    This makes the EA incompatable with every other including itself on other charts and manual trading. Use a magic number in the orderSend and
    int total_trades = 0;
        for(iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
            OrderSelect(iPos, SELECT_BY_POS)                // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol()                 // and my pair.
        ){  total_trades++;  }
    if (total_trades ...
    

  3. int ticket2=OrderSend(Symbol(),OP_BUY ...
    Always test return codes. Change to 'int ticket=' and delete the int from the sell's 'int ticket='
 

I get an error when I try to use the insert image.

I pasted a screen shot into a word doc. and tried to upload that... no luck either.

I'm trying to just attach that file. let me know if you get the screen shot that way. I don't see it.


	          
 

y word use mspaint save as a jpg or gif

 
qjol:

y word use mspaint save as a jpg or gif


Thanks... never tried mspaint before. but it was on my computer.

Reason: