Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via WebMoney
Cerberus
73
Cerberus 2014.05.02 09:05  

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
13993
whroeder1 2014.05.02 12:05  
Cerberus: But OnTick is an MQL5 function isn't it??
Event Handling Functions - MQL4 Documentation
Keith Watford
Moderator
8882
Keith Watford 2014.05.02 13:05  
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 2014.05.02 13:39  
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
8882
Keith Watford 2014.05.02 14:07  
Cerberus:


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