Source Code: input int TimeStartHour = 7; input int TimeStartMin = 10; input int TimeEndHour = 15; input int TimeEndMin = 10; void OnTick(){ MqlDateTime structTime; TimeCurrent(structTime); structTime.sec = 0; structTime.hour = TimeStartHour; structTime.min = TimeStartMin; datetime timeStart = StructToTime(structTime); structTime.hour = TimeEndHour; structTime.min = TimeEndMin; datetime timeEnd = StructToTime(structTime); bool isTime = TimeCurrent() >= timeStart && TimeCurrent() < timeEnd; Comment(" Server Time: ",TimeCurrent(), " Time Start Dt: ",timeStart, " Time End Dt: ",timeEnd, " Time Filter: ",isTime); }
@ramni89ramni2 жыл бұрын
Hi please i need your help the robor not work when my pc is offline what can I do...? Or is must be always online ..? Thank you brother
@ReneBalke2 жыл бұрын
@@ramni89ramni Yes. The PC (and the MetaTrader) has to run all the time. A lot of trader use a VPS. Check out my last video where I show how to setup a VPS.
@kajinguludan58862 жыл бұрын
Hi, I wanted to ask, how do i extract the importance using mqlcalendarevent and use it in another if statement? kindly help? i want to filter the importance
@tradelicious88192 жыл бұрын
Hey Rene, i'm trying to add time filter to my existing EMA strategy. It gives me "OnTick" -function already defined and has body. When i deletes or moves it it gives so many other errors. Please help
@erickkillian55902 жыл бұрын
Thank you very much for this! However, when I add this code to my existing EA, I get an "OnTick" function already exists. How/Where do I add this time filter source so that it will take the entries based on my EA? Thank you.
@YoussufOthman9 ай бұрын
My Freind Let Me Buy you a coffee for the valuable information, believe me i had zero understanding about EAs before 15 days and now i developed 45% producing per day EA. i know my previous programming knowledge helped but indeed you taught me everything about EAs that i need just watching KZbin Videos in your channel. so know i have an EA that working but indeed you owns it. thank you so much
@fulkrumfx2 жыл бұрын
Thank you for taking my suggestion!
@philtradinglune5297 Жыл бұрын
will be thankful for having tutorial about setting news filter to disable the ea for certain news or times before and after
@haydenlyon60562 жыл бұрын
I swear your making videos just after i finish struggling through them! I suppose next youll be writing a news filter! Lol. Love the work! Any new coder that finds your videos probably doesnt know the value of what your sharing!
@shadowwarsshadypeople62992 ай бұрын
Thank you, you just helped me tremendously. I had to swtich from Ctrader to MT5 due to the new Ctrader update, and been working on fitting the code to MT5, but time restriction I was using was not working. Thanks again :)
@markonis1002 жыл бұрын
This content is really helpful. I already implement a time filter in my EA but your method is different. I love how your content is expand the viewer's knowledge.
@erickkillian55902 жыл бұрын
Can you share your script for the time filter in your EA, please? I am using this one, and I can't seem to place it in the right location? Maybe just share where in the script you are placing your time filter at? Thank you.
@bitestonk0618 Жыл бұрын
bedanya kalau penyaring waktu dipakai dalam OnTick() dan OnTimer apa ?
@markonis100 Жыл бұрын
@@bitestonk0618 Saya gak pernah pakai OnTimer, Om. Kebetulan saya belajar coding EA baru 6 bulan-an dan belum pernah pakai OnTimer. Kalau di OnTick, time filternya dicek setiap tick baru (setiap ada pergerakan harga sekecil apapun).
@bitestonk0618 Жыл бұрын
@@markonis100 boleh share pakainya dimana?
@philippedecamp7558 Жыл бұрын
Great !! Thank You René ! So simple when we follow you.
@steveg40512 жыл бұрын
Excellent as all of your tutorials are. I think with this look at accessing time i might be able to get a news filter going. Am looking forward to getting some profit banked to then invest time and money on your course.
@amirhosseinghavi305 ай бұрын
Excellent tutorial. learned a lot.🙏🙏
@jovidwaakzaam18652 жыл бұрын
very nice,in my oppinion a daytime filter is handy if you wanna avoid like the nfp or maybe certain high impact news on certain days
@Kariboo925 Жыл бұрын
Hi Rene for my part, I prefer to use datetime type input. It is easier for backtest optimizations. You have starttime & stoptime on the same 3D graph Great work anyway.
@kisuulegodwin Жыл бұрын
Hello Rene I have learnt alot in your teaching, loved it so much . Though am kindly requesting you to do a video on neural network tradebot in mql5
@MrHumbleOne Жыл бұрын
A great video as usual, I wonder if I should put this in a custom function and store the results as a defined variable rather than have all the code in my on tick function, I have lots of calculations that’s are called and wonder if I should build outside of the OnTick function
@rideyourlife14182 жыл бұрын
Thank you! Your tutorial is really helpful!
@farbeyondtrading Жыл бұрын
p.s. I love your videos!! Thanks for teaching us, and letting us enjoy your accent :)
@ReneBalke Жыл бұрын
:D
@lukageldenhuys Жыл бұрын
Thanks, René! How would you go about if the start time is "later" than the end time? E.g., start at 02:00 and end at 18:00 the next day. TIA.
@fearwin6 ай бұрын
Hi , is it this filter and variable set up must be put inside OnTick? which machine would do everytime a tick come and waste lot of CPU resources. Can it be put on say OnInit()? so the machine only declare the variable once and the filter then put in OnTick?
@andrasgosztola96152 жыл бұрын
Nice tutorial !! Maybe in the can you make a "partial close at a custom distance" tutorial. A tried to create one, but something not working very well Thanks
@erickkillian55902 жыл бұрын
He has a "partial close" video.. Here is the link, I hope that it helps kzbin.info/www/bejne/fWHUmWeHrr2Yj5Y
@andrasgosztola96152 жыл бұрын
@@erickkillian5590 Thank you
@leonardoampuero7235 ай бұрын
I am a bit confused with timezone. I want to set trading hours to NY sessions. but it seems that metatrader is using GMT+3, any idea how to set this to make the strategy tester work accordingly?
@andymukotekwa96569 ай бұрын
Hey rene I've been trying to create a time based execution EA which executes trades based on the input of time of my choice up to the second, has inbuilt SL AND TP and allows me to select whether i want to enter a buy trade or a sell, the code I have has no errors but is not executing trades., can yu help
@Jaypipin Жыл бұрын
Hello Rene, nice material! So i have an issue with EA in that one broker starts day 0.00 gmt then another -2.00 gmt so could be sunday 22.00 Now broker B which starts Sunday creates issues. Such as indicator will use sunday data could be 2 hrs for monday support /res lines. This is a mistake. It should use friday data. So if your video about this issue? Also for backtesting, say i want my 4hr indicator using SR lines, to start 22.00 server time not their 0.00 so -2 hrs.
@nesmill992 жыл бұрын
Hey Rene, Love your content you are very clear and straight forward and funny as well xd Could you show please how to create a countdown of the time left for the current candle to close, I have been trying to get that working for a few days and nothing.
@ReneBalke2 жыл бұрын
Thank you :) I think you will find a lot of solutions for this if you google it. this is a really common program for mt5 :)
@Joerg632 жыл бұрын
Hi Rene, thanks for your great explanation and besides you are doing a fantastic job. Now to my question. I`ve tried to implement the Time Filter to the Supertrend Expert you also wrote and explaned. I placed the Time filter right under the "void onTick(){" and it shows the right time statement like true or false when I start the strategy tester, but the advisor didn`t recognize the choosed time filter in the program, means he will open and close the position when a signal appears no matter what time it is. I suppose there is an additional loop in the main Program? please advise and thanks ...dickes Danke aus Bielefeld
@glauberpcp13 ай бұрын
how can i set this at the dark point ea?
@TheJoshuamcgowan Жыл бұрын
You’re awesome ❤
@nabilnakiri-w6d9 ай бұрын
hello how I set time Gmt-4
@Fggghijub11 ай бұрын
Excellent🙏
@mwa5330 Жыл бұрын
Can we add multiple set of trading time?
@christianalegria6132 Жыл бұрын
hello what code do you use to hightlight this filtered time. thank you
@nilsmueller812 жыл бұрын
Hi Rene. That was really helpfull for me. Can only use hours and minutes? Or can i take the hole date + Time?
@ReneBalke2 жыл бұрын
Hey, you could also use a specific point in time. The easiest way would be using a datetime input straight away I think.
@mwa5330 Жыл бұрын
Time filter not work, I pasted this my heiken ashi but not working
@supermarketfx10 ай бұрын
Is there a way to change this to prevent any trades open during news events? I want to be able to prevent any EA on MT5 from trading during an upcoming news event.
@ReneBalke10 ай бұрын
Yes you could use the mt5 calendar api for example
@acky888888882 жыл бұрын
Can we have the input like "input datetime TimeStart = 15:00;" but without the date?
@ReneBalke2 жыл бұрын
No in this case you have to use a string input.
@relaxingmood32102 жыл бұрын
Can you create EA that trade only divergence on anytime frame like 30 mins, 1hrs...
@pbayat6667 Жыл бұрын
Thanks 🙏
@JasonHothamMBA2 жыл бұрын
This is great thanks! I know I should probably look around but the time shown doesn't show my machine time (actually time). I'm in the UK and the time shown in MT5 is 1 hour behind, and the server time is 2 hours ahead. What code could I add to show my machine time please?
@ReneBalke2 жыл бұрын
You can use TimeLocal()
@JasonHothamMBA2 жыл бұрын
@@ReneBalke great thanks!
@juniorivvypr79322 жыл бұрын
rene please where should i put this code.. it seems if i put on "OnTick" function it doesnt filter when i run the tester
@ReneBalke2 жыл бұрын
Hey, yes. You can check the time filter before you open a position.
@yagneshacharya24612 жыл бұрын
i want that my pending order will expire after 1 minute , pleasse help me out
@rickscreations3159 Жыл бұрын
There is an error in your code : if the user sets StartTimeHour = 21 StartTimeMin = 0 EndTimeHour = 9 EndTimemin = 0. because the user wants to trade after NYC is finished and trade the AUD and ASIA Market time. your Time filter will not run. it will think that it is going from. 21pm -9am. ON the same day. your Code has no consideration for Midnight. you should update this.
@kroedis Жыл бұрын
How would you fix that
@cwleo1 Жыл бұрын
Great tutorial. But I guess this algorithm doesn't cater for trading period that span across midnight of the broker's timezone. e.g. TimeStartHour = 21 (9pm today) and TimeEndHour = 4 (4am tomorrow). For such scenarios, this equation will never return true. bool isTime = TimeCurrent() >= timeStart && TimeCurrent() < timeEnd;
@kroedis Жыл бұрын
How do we fix that
@alexanderwening89592 жыл бұрын
thx :-*
@growmybusinessonline571111 ай бұрын
Hi Rene excellent thank you very useful video ! May I please ask - building on this time filter how can you draw a colored box around that filtered time period. All prior day boxes remain and do not get deleted so you can see that time filter each day eg DAX 8am to 10am box or rectangle
@ReneBalke11 ай бұрын
You can learn it in my course: en.bmtrading.de/mt5-masterclass/