Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

MQL4 TUTORIAL BASICS - 75 SIMPLE TIME FILTER

Автор: MQL4Tutorial

Загружено: 2020-06-20

Просмотров: 11097

Описание:

https://mql4tutorial.com

With MQL4 for Metatrader4 we create an Expert Advisor to allow or disallow trading based on a start time and a stop time. We are using datetime to get the current time and allow or disallow automated trading.

In this video we will create a filter that is going to allow or disallow trading based on the current time so let's find out how to do that with mql4.
To get started please click on a little icon here or press F4 on your keyboard. Now you should see the Metaeditor window and here you want to click on file, new file, expert advisor from template, continue, I will call this file, simple time filter, click on continue, continue and finish.
Now you can remove everything above the ontick function and the two comment lines here.
We start by creating an input string for the start trading time, this one is set to 9:00 am but I will change it to 1:00 am in this case, the input modifier will allow any user to change the values in the expert properties tab without any recompilation, we also need a stop trading time, this is set to 10:00 am so trading will be allowed between 1:00 am and 10:00 am, obviously we need to find out if the current time is between those two timestamps, so let's create a variable current time, and finally, we want to allow or disallow trading that's done with this variable, trading is allowed, it's a bool so it can either be true or false.
Inside of the ontick function, we start by getting the current time that's a datetime variable and we are using the function time local, so let's mark that and press F1 and we learn that it returns the local time of the computer where the client terminal is running so that's your PC and in the next step we use time to string to convert the time that we have calculated, we want to use a special format called time underscore minutes, let's mark that and press F1 and now you see that we will get this format, hours and minutes divided by a colon.
To check for the entry conditions we are going to use a function that is called check trading time and if the return value is true we consider to open a position, this function doesn't exist so far so we need to code it later on.
The second entry condition will be if orders total returns a value of zero so this is true when we have no open orders or no open positions and if both conditions are true we are going to use order send to buy ten micro lot. Obviously, you wouldn't do that on a real account you would add other things like entry signals from an indicator or something like that but for this simple example, it's good enough.
Let's add a chart output the comment statement will output if trading is allowed, the current time, the start trading time and the stop trading time that we have defined but now we need to create this function here, it is called check trading time and it's boolean so it can either return true or false.
In mql4 that will be represented by zero for false and one would be true and to set the trading allowed variable we are going to look into the current time, we are using string substring to find a certain value and the value that we are looking for is the start trading time, let's mark that and press F1.
String substring has an original string and we are going to look for the value inside of the string, the starting position in our case is zero, the second parameter is for the length of the substring, in our case it's five and if we can find the defined start trading time within the current time we will set the trading is allowed variable to true.
Otherwise, if the current time contains the defined stop trading time we would set the trading is allowed variable to false.
Finally, we use the return statement to return the trading is allowed result to the main function and that's about it.
If this was too fast for you or if you have no idea what all the code here does maybe you want to watch one of the other videos in this basic video series first or maybe even the premium course on our website might be interesting for you. This was another suggestion that came from a premium course member and if you are already a premium course member and have an idea for a video like this one please let me know. For now, please click on the compile button or press F7 on your keyboard you shouldn't get any errors here and if this is the case you can click on a little button here or press F4 to go back to Metatrader.
And inside Metatrader we click on view, strategy tester or press control and r, please pick the new file simple time filter dot ex4, mark the option for the visual mode here and start your test.
Here we are! The current start writing time is 1:00 am so within a few seconds we should see the first position right here on the chart and the filter should switch to one, that happened right now, now let's click on stop, go to the expert properties and we are going to change the start reading time here, restart the test and this time we should see the first trade

MQL4 TUTORIAL BASICS - 75 SIMPLE TIME FILTER

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

MQL4 TUTORIAL BASICS - 89 SIMPLE HIGH PRICE TREND LINE

MQL4 TUTORIAL BASICS - 89 SIMPLE HIGH PRICE TREND LINE

LEARN MQL5 TUTORIAL BASICS - 75 SIMPLE TIME FILTER

LEARN MQL5 TUTORIAL BASICS - 75 SIMPLE TIME FILTER

MQL4 TUTORIAL BASICS - 56 SIMPLE CLOSE TIMER

MQL4 TUTORIAL BASICS - 56 SIMPLE CLOSE TIMER

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

Но что такое нейронная сеть? | Глава 1. Глубокое обучение

MQL4 TUTORIAL BASICS - 78 SIMPLE MULTI CURRENCY ORDER

MQL4 TUTORIAL BASICS - 78 SIMPLE MULTI CURRENCY ORDER

Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение!

Где начало СХЕМЫ? Понимаем, читаем, изучаем схемы. Понятное объяснение!

MQL4 TUTORIAL BASICS - 73 SIMPLE SPREAD FILTER

MQL4 TUTORIAL BASICS - 73 SIMPLE SPREAD FILTER

MQL4 TUTORIAL BASICS - 40 SIMPLE BUY BREAKEVEN STOP

MQL4 TUTORIAL BASICS - 40 SIMPLE BUY BREAKEVEN STOP

you need to learn BASH Scripting RIGHT NOW!! // EP 1

you need to learn BASH Scripting RIGHT NOW!! // EP 1

Задача из вступительных Стэнфорда

Задача из вступительных Стэнфорда

Разведчик о том, как использовать людей

Разведчик о том, как использовать людей

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Изучите Wireshark! Учебник для начинающих

Изучите Wireshark! Учебник для начинающих

[2026] Feeling Good Mix - English Deep House, Vocal House, Nu Disco | Emotional / Intimate Mood

[2026] Feeling Good Mix - English Deep House, Vocal House, Nu Disco | Emotional / Intimate Mood

MQL4 TUTORIAL BASICS - 82 SIMPLE SMA TRAILING STOP LOSS

MQL4 TUTORIAL BASICS - 82 SIMPLE SMA TRAILING STOP LOSS

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

LLM и GPT - как работают большие языковые модели? Визуальное введение в трансформеры

How to run MQL4 or MQL5 code only one time for each bar

How to run MQL4 or MQL5 code only one time for each bar

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

Учебник по Excel за 15 минут

Учебник по Excel за 15 минут

Что такое TCP/IP: Объясняем на пальцах

Что такое TCP/IP: Объясняем на пальцах

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com