Fixing the order opening logic

MQL5 Traduzione

Lavoro terminato

Tempo di esecuzione 7 giorni
Feedback del cliente
Good work, thanks for a good feedback
Feedback del dipendente
Great customer. Fast communication. I look forward to working with you again.

Specifiche

Problem description
False trades at transition of a trading session to the next day
At a price gap (a sharp jump in the spread) at the beginning of a new session, the Expert Advisor repeatedly opens deals with the same volume, although the logic should block new orders if the spread exceeds the max_spread threshold.

No possibility to set a “quiet” interval between sessions
The robot does not know how to skip trading in a predefined time interval (for example, from 23:50 to 00:10), which aggravates the effect of false signals on gaps.

Insufficient protection at increased spread
The current IsSpreadTooHigh() method only stops opening once, but does not guarantee that the spread has not decreased and new orders have not been opened at the moment of checking.

Goals and Objectives
Goal: Eliminate false trades on gaps and give traders a flexible tool for “quiet” periods between sessions.

Objectives:

Diagnosing and fixing bugs that lead to multiple openings at high spread.

Adding new input parameters for setting a “quiet” interval between sessions.

Strengthening the logic of protection against opening trades at high spread.

Input parameters (add):
mql
Copy
input int spread_cooldown = 30; // Quarantine time after spread exceeding (in seconds)

input bool check_on_every_tick = true; // Repeat spread check not only in OnTimer, but also in OnTick.

2 Setting a “quiet” interval between sessions
Requirement FT-2.1
Input parameters for the time range in which trading is completely disabled:

mql
Copy
input datetime session_break_start = D'1970.01.01 23:50'; // Quiet period start time
input datetime session_break_end = D'1970.01.01.02 00:10'; // Quiet period end time
Requirement FT-2.2
Check at the beginning of each cycle in OnTimer() and OnTick():

mql
Copy
datetime now = TimeCurrent();
if(InSessionBreak(now))
   return; // Completely skip the logic of opening/managing orders
where InSessionBreak() returns true if session_break_start ≤ now.time_of_day < session_break_end.

3Diagnosis and elimination of false trades
Requirement FT-3.1.
Audit ManageBuyPositions() and ManageSellPositions() - ensure that check_position_*() and IsSpreadTooHigh() are called before each new trade.Buy()/Sell().

Requirement FT-3.2
Add a centralized wrapper function CanOpenNewOrder() that integrates:

magick count number check;

check of “quiet” interval;

spread check;

check of position repetition.


File:

Con risposta

1
Sviluppatore 1
Valutazioni
(274)
Progetti
346
29%
Arbitraggio
36
28% / 64%
In ritardo
10
3%
Caricato
2
Sviluppatore 2
Valutazioni
(3)
Progetti
6
17%
Arbitraggio
0
In ritardo
1
17%
Gratuito
Pubblicati: 3 codici
3
Sviluppatore 3
Valutazioni
(14)
Progetti
14
14%
Arbitraggio
8
0% / 88%
In ritardo
2
14%
Caricato

Informazioni sul progetto

Budget
50+ USD
Scadenze
a 5 giorno(i)