You can do it in easy way. Just add EA start_hour & end_hour in your EA opening condition. Also you can specify same for specific pairs.
input int start_hour = 8; input int end_hour = 16; // 24 hour format int OnInit(){ // Set different time hour for different symbols if(_Symbol=="GBPUSD"){ start_hour = 8; end_hour = 16; } if(_Symbol=="JPYNZD"){ start_hour = 2; end_hour = 10; } } // Convert TimeCurrent() to struct // Trade Open conditions if(condition01 && condition02 && timecurrent.hour>=start_hour && timecurrent.hour<=end_hour){ // Codes ....... }
You can do it in easy way. Just add EA start_hour & end_hour in your EA opening condition. Also you can specify same for specific pairs.
Thank you very much for the reply @Mahadi Hasan Razu!
I'll add this to my code and give it a try. I'm currently building my first bot so wont be able to tell if I have it working for a few days but I just wanted to say thank you first.
CPerry.
When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours and fraction can be inputs.
Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi forum,
As per the title of the thread, if I have a standard RSI EA running that I'd like to run only between a certain period of the day, is there a nice easy way of doing this? What about if I only want new positions to be limited to a time-frame but closing orders may still work?
What about if I want variations of the bot for a bunch of different currency pairs? For example, the exact same bot mechanically, I want it to run between 8am and 4pm on GBP/USD but between 2am and 10am on the JPY/NZD?
Thank you for taking the time to look at this,
CPerry.