Download MetaTrader 5

EA won't place a trade - page 3

To add comments, please log in or register
Cerberus
73
Cerberus  

Ok well start wasn't working for me, as soon as I changed it to OnTick it worked..

But OnTick is an MQL5 function isn't it??

whroeder1
15598
whroeder1  
Cerberus: But OnTick is an MQL5 function isn't it??
Event Handling Functions - MQL4 Documentation
Keith Watford
Moderator
10569
Keith Watford  
Cerberus:

Ok well start wasn't working for me, as soon as I changed it to OnTick it worked..

But OnTick is an MQL5 function isn't it??


Just to clear things up

Can you please show your code that works with OnTick that doesn't work with start()

Cerberus
73
Cerberus  
void OnTick() 

   {
   double BSL     = NormalizeDouble((Bid - 400*Point),Digits);
   double BTP     = NormalizeDouble((Bid + 400*Point),Digits);
   double SSL     = NormalizeDouble((Ask + 400*Point),Digits);
   double STP     = NormalizeDouble((Ask - 400*Point),Digits);
   int    MinStop = MarketInfo(Symbol(), MODE_STOPLEVEL);
   
   if(MinStop > 400) {
      Alert("Minimum stop distance allowed is: ",MinStop);
   }
   
   if (iMA(NULL, 0, 3, 0, MODE_EMA, 0, 1) > iMA(NULL, 0, 10, 0, MODE_EMA, 0, 1)) {
      int order = OrderSend(Symbol(), OP_BUY,1,Ask,10,BSL,BTP);
      if(order < 0) {
         Alert("trade not placed");
      }
   }
   Alert(GetLastError());
   
   if (iMA(NULL, 0, 3, 0, MODE_EMA, 0, 1) < iMA(NULL, 0, 10, 0, MODE_EMA, 0, 1)) {
      int order = OrderSend(Symbol(), OP_SELL,1,Bid,10,SSL,STP);
      if(order < 0) {
         Alert("trade not placed");
      }
   }
}
Keith Watford
Moderator
10569
Keith Watford  
Cerberus:


That code works in start() as well with 625 and 914
Keith Watford
Moderator
10569
Keith Watford  
Incidentally, so does your original code.
Cerberus
73
Cerberus  
Weird okay.. I'll try it again. But thanks everyone for the help!!
123
To add comments, please log in or register