Download MetaTrader 5
To add comments, please log in or register
Have you developed a trading robot? Publish it in the Market and make profit!
shyftus
195
shyftus 2014.03.23 06:34 
   if (Bars != ThisBarTrade ) 
   ThisBarTrade = Bars;
   if(_AND && !__isExist(0))_Open_Position = OrderSend(Symbol(),0,_Arithmetic,MarketInfo(Symbol(),MODE_ASK),0,MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_POINT)*35,MarketInfo(Symbol(),MODE_ASK)+MarketInfo(Symbol(),MODE_POINT)*168,"RSI Buy",__STRATEGY_MAGIC + 0)>=0;
   if(_AND_2 && !__isExist(0))_Open_Position_2 = OrderSend(Symbol(),1,_Arithmetic,MarketInfo(Symbol(),MODE_BID),0,MarketInfo(Symbol(),MODE_BID)+MarketInfo(Symbol(),MODE_POINT)*35,MarketInfo(Symbol(),MODE_BID)-MarketInfo(Symbol(),MODE_POINT)*168,"RSI Sell",__STRATEGY_MAGIC + 0)>=0;
   return(0);

No errors but continues to open multiple trades when stopped out during signal bar. Any help would be much appreciated.

Cheers.

Keith Watford
Moderator
7873
Keith Watford 2014.03.23 06:50  

You don't instruct the EA to do anything if the condition is false and when the condition is true, it justs assigns a value to the variable ThisBarTrade

line 2 is conditional on line 1, then it will continue with the rest of the code

whroeder1
13593
whroeder1 2014.03.23 12:25  
Your code
   if (Bars != ThisBarTrade ) 
   ThisBarTrade = Bars;
   : // every tick
Equivalent
   if (Bars != ThisBarTrade ) ThisBarTrade = Bars;
   : // every tick
Try
: // every tick
static datetime timeNow; datetime timePrev = timeNow; timeNow = Time[0];
if (timeNow != timePrev) {
   : // Once per bar
}
: // every tick
Don't use bars, if new history is downloaded, Bars changes. Don't use tick volume, you can miss ticks. Always use time. See also resetting statics
/
To add comments, please log in or register