Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1512

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can anyone suggest the following code:
If a grid of orders is CLOSED (more than 2 of the same type), then STOP TRADING until the end of the day (or some time which can be set in hours, minutes).
Counting history as found on the same order types still somehow able to, but how to stop at the end of the day precisely do not know. Happy Pentecost to all)
not normal, eight bytes would be a pain in the ass to send something
Well, it depends on the purpose, if it's just a reminder, then eight is enough :)
Can anyone suggest the following code:
If a grid of orders is CLOSED (more than 2 of the same type), then STOP TRADING until the end of the day (or some time which can be set in hours, minutes).
Counting history as found on the same order types still somehow able to, but how to stop at the end of the day precisely do not know. Happy Pentecost to all)
Can anyone suggest the following code:
If a grid of orders is CLOSED (more than 2 of the same type), then STOP TRADING until the end of the day (or some time which can be set in hours, minutes).
Counting history as found on the same order types still somehow able to, but how to stop at the end of the day precisely do not know . Happy Holy Trinity to everyone)
/// получаем время конца (по умолч.текущего) дня. То есть время последней секунды дня
datetime EndOfDay(datetime tim=0) {
if (tim==0) tim=TimeCurrent();
datetime dt;
TimeToStruct(tim,dt);
dt.hour=23;
dt.min=59;
dt.sec=59;
return StructToTime(dt);
}
/// где-то в торговой логике, отрывки
datetime tradeAllowedFrom; // в глобальной области
....
tradeAllowedFrom=EndOfDay(); // где сетку проверяем : запрещаем торговлю до конца дня
....
if (TimeCurrent()>tradeAllowedFrom) { // проверка разрешения торговли
Buy(); // Sell();
}
If I understood the question correctly, it is approximately like this (the principle itself)
Well, it depends on what purpose, if just to remind of yourself, then eight is enough :)
if you want to remind yourself, it's better to throw a custom event into OnChartEvent(), it's more convenient, imho
MakarFX:
Who can suggest the following code:
if grid of orders is CLOSE (more than 2 of the same type), then STOP TRADING until end of day (or some time which can be set in hours, minutes).
search through the orders history from the date of the day's beginning (today, or from TF D1 to get a zero bar or from a datetime tick time to convert)
if at least one order has been found in the history with a date greater than the set one - exit the function, resulting in true
in OnTick() at the very top of the call of such a function with the date parameter (today)
I'm too lazy to write it, there are about a dozen lines. Kim had functions to search for orders in the history by date
/// получаем время конца (по умолч.текущего) дня. То есть время последней секунды дня
datetime EndOfDay(datetime tim=0) {
if (tim==0) tim=TimeCurrent();
datetime dt;
TimeToStruct(tim,dt);
dt.hour=23;
dt.min=59;
dt.sec=59;
return StructToTime(dt);
}
/// где-то в торговой логике, отрывки
datetime tradeAllowedFrom; // в глобальной области
....
tradeAllowedFrom=EndOfDay(); // где сетку проверяем : запрещаем торговлю до конца дня
....
if (TimeCurrent()>tradeAllowedFrom) { // проверка разрешения торговли
Buy(); // Sell();
}
if I understood the question correctly, it goes something like this (the principle itself)
trade sell / trade buy - function how!?
If anything, it's taken from here.
I'm new to programming, not very good, can you redo it and make it available for download ???