EA sending a mass of "SendMessage" commands despite prevention code in place

EA sending a mass of "SendMessage" commands despite prevention code in place

Manage alerts

Loading saved threads...

user13805328 · External communityPost link
External question — Stack Overflow Stack Exchange Author: user13805328 Original post: https://stackoverflow.com/questions/62633417 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Morning Fellow Stackoverflowers I'm currently testing out some code which is based around time of day with which an EA is allowed to trade. How would I prevent the EA from sending a bazillion emails - one will obviously do. Only one was sent in another EA I have by applying LastActiontime=Time[0]; , however, having applied the LastActiontime=Time[0]; , its pinging a mass of messages.... What changes do I need to make to prevent this from happening? See code below //+------------------------------------------------------------------+ //| EAServerVerificationPing.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict datetime LastActiontime; int timeOfDay; int hour; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- RefreshRates(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- timeOfDay = DayOfWeek(); hour = Hour(); if(timeOfDay == 1 && hour >= 2) if(LastActiontime!=Time[0]) { //Code to execute once in the bar SendMail("Is your Trade Allowed? (FXVM)", "Yes, your trade is allowed"+ "\n"+ "\nPRIVACY NOTICE"); }else{ SendMail("Is your Trade Allowed? (FXVM)", "No, your trade is not allowed"+ "\n"+ "\nPRIVACY NOTICE"); } LastActiontime=Time[0]; <!------This should prevent a mass of messages from sending---> } //+------------------------------------------------------------------+ Much obliged :)
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: user13805328 Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/questions/62633417 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Morning Fellow Stackoverflowers I'm currently testing out some code which is based around time of day with which an EA is allowed to trade. How would I prevent the EA from sending a bazillion emails - one will obviously do. Only one was sent in another EA I have by applying LastActiontime=Time[0]; , however, having applied the LastActiontime=Time[0]; , its pinging a mass of messages.... What changes do I need to make to prevent this from happening? See code below //+------------------------------------------------------------------+ //| EAServerVerificationPing.mq4 | //| Copyright 2017, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict datetime LastActiontime; int timeOfDay; int hour; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- RefreshRates(); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- timeOfDay = DayOfWeek(); hour = Hour(); if(timeOfDay == 1 && hour >= 2) if(LastActiontime!=Time[0]) { //Code to execute once in the bar SendMail("Is your Trade Allowed? (FXVM)", "Yes, your trade is allowed"+ "\n"+ "\nPRIVACY NOTICE"); }else{ SendMail("Is your Trade Allowed? (FXVM)", "No, your trade is not allowed"+ "\n"+ "\nPRIVACY NOTICE"); } LastActiontime=Time[0]; <!------This should prevent a mass of messages from sending---> } //+------------------------------------------------------------------+ Much obliged :)

Cancel quote

Checking account access…