Help please ?

 

Hi all,

First - please excuse my ignorance in MQL4, I'm still a newbie when it comes to this one, your patience is appreciated.

I'm trying to create an EA based on 'Urban Forex 10 Pips Scalping' strategy (http://www.urbanforex.com/forex-trading-strategies/68-10-pips-per-day-scalping-strategy)

This is what I've got so far

------------------------------------------------------------------------------------

int start(){

//---- Find setup for SHORT TRADE
if (Close[2] > Open[2]){ //Find a LONG candle
if (Open[2] > iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,2)){ //Make sure that it starts WITHIN the bollinger and crosses the UPPER band
if (Open[2] < iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,2)){
if (Close[2] > iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,2)){
if (iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0) >= 80){ //Make sure that stochastics are 80 or above
if (iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0) >= 80){
if (Close[1] < Open[1]){ //Checks if the 'next' candle is SHORT
HERE IS WHERE I'M STUCK <------- //Enter SHORT trade on next open ????
}
}
}
}
}
}

}

}

---------------------------------------------------------------------------------------------------

This code should find the setup conditions for a SHORT trade, and then place an order on the next OPEN.

I don't know how to send the order ONLY on the next open ?


In anycase, any help is much appreciated!

Thanks in advanced (-!

 
ujchandler:

I don't know how to send the order ONLY on the next open ?

This is nice and easy ...

// define outside of functions (global)
datetime newBar;

// in the init function
    newBar = Time[0];

int start(){

   if( newBar >= Time[0] ) // nothing to do here
      return( 0 );

   newBar = Time[0];

   // we only get here at the start of a new bar

  // now do your indicator and testing stuff
}
 
int start(){
   static datetime Time0; if (Time0 == Time[0]) return; Time0 = Time[0];
   // Below is called once at the start of a new bar.
Reason: