Download MetaTrader 5
To add comments, please log in or register
Improve your rating. Execute orders in Freelance service!
BigAl
489
BigAl 2012.11.20 12:27 

new to this - How can I stop a new tick event (OnTick) from executing (or get out of it). Tried using  if (!TERMINAL_TRADE_ALLOWED) return; but as stated that does not stop the event.

I need to do this as in the event i want to place a trade or report back the error if it fails.

Without allowing trading (while working on my code) if the the EA is attached to the chart the error saying it cannot trade is shown every tick. So I have to remove the EA from the chart

to stop the messages which is rather annoying

phi nuts
2184
phi nuts 2012.11.20 14:45  
BigAl:

new to this - How can I stop a new tick event (OnTick) from executing (or get out of it). Tried using  if (!TERMINAL_TRADE_ALLOWED) return; but as stated that does not stop the event.

I need to do this as in the event i want to place a trade or report back the error if it fails.

Without allowing trading (while working on my code) if the the EA is attached to the chart the error saying it cannot trade is shown every tick. So I have to remove the EA from the chart

to stop the messages which is rather annoying


If the purpose of this is just to limit some Alert(), then count it.

static int Alarm_1;

if (error == true)
   {
   if (Alarm_1 <= 3)
      {
      Alert ("You have annoying error ",error);
      Alarm_1 ++;
      }
   }
   else
   {
   Alarm_1 = 0;
   }
Rogerio Figurelli
Moderator
39471
Rogerio Figurelli 2012.11.20 22:31  
Hi, as you are a newbie my suggestion is use Print to debug OnTick code before start to use Alert, because you can check your code without Alert annoying messages. After you reach stability in your code, you can start use Alerts.
Documentation on MQL5: Common Functions / Print
Documentation on MQL5: Common Functions / Print
  • www.mql5.com
Common Functions / Print - Documentation on MQL5
BigAl
489
BigAl 2012.11.20 23:28  
figurelli:
Hi, as you are a newbie my suggestion is use Print to debug OnTick code before start to use Alert, because you can check your code without Alert annoying messages. After you reach stability in your code, you can start use Alerts.

Thanks for the 2 suggestions. I will use debug to start and once happy with that then use Alert if I still have problems. Still do not understand why if trade is not allowed events are still activated though, if you know please tell me just to satisfy my curiosity

thanks to those who responded

Rogerio Figurelli
Moderator
39471
Rogerio Figurelli 2012.11.22 01:18  
Note that you are using OnTick event, so you will get all ticks of the chart instrument and there is no relation to sending orders or not in this event. If you take care about using right flags to detect and filter trends before send orders you will get the solution, because you will mask the ticks info you don't need.
phi nuts
2184
phi nuts 2012.11.22 02:26  
BigAl:

Thanks for the 2 suggestions. I will use debug to start and once happy with that then use Alert if I still have problems. Still do not understand why if trade is not allowed events are still activated though, if you know please tell me just to satisfy my curiosity

thanks to those who responded

Trade is not allowed only make EA/Script can not trade, but it does not stop tick from coming in and execute EA/CI.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
/
To add comments, please log in or register