Topic: Suspend and delay signals when market is off around midnight

Hello traders,

I want to add a fix in the EA's code to work around the problem with the brokers that suspend the trading around midnight for swap calculations.

The problem appears when we trade mostly on D1, H4, or H1 charts and the strategy has a signal at 00:00 but the market is off.

A possible solution is to "remember" the signals and execute it when the market is open.

We have to add some limitations for how long the signal can be delayed.

A possible workflow is:
- save the signal if the market is closed
- periodically check if the market is open (let's say every 15 seconds)
- send the order if the market is open.
- cancel the signal if the market is closed for longer than N minutes. Log a message.

I also want to have a predefined time for this procedure. Let's say:


We can add these options in the EA Studio's Settings. Something like that:
  [ V ] Enable signal delay on Market Closed
            Expected Market Closed time start:  23:55
            Expected Market Closed time end:   00:05
            Maximum time for signal delay in minutes: 2.0
            Retry interval in seconds: 15

Please share your opinion.

If you have a working code, please share it. It will help us to come with a faster and more stable solution.

Re: Suspend and delay signals when market is off around midnight

I posed this problem years ago, now that trading is my only job I try to give advice: "save the signal if the market is closed" is the only answer that makes sense to me. No software corrects the swap and spread problem in the cfd and forex, as a result all the strategies become distorted. Is necessary the transition from automatic to quantitative-discretionary trading.
It would be better to focus on something else

Ragards

Re: Suspend and delay signals when market is off around midnight

Finally, we've been waiting for this.

I think the best way of doing this is to add parameter MaxPriceDeviation = 0.1 which is 0.1% of the open price.
When the market is available again the EA will place the trade only if the entry price is within 0.1% range. Otherwise, the signal is missed.


> - cancel the signal if the market is closed for longer than N minutes. Log a message.

I do not think this is a good idea, especially in 2 minutes time. Markets might be closed for rollover for 20 minutes. With GBE brokers that's normal. And when the markets are back again the price might be very reasonable.

This problem of market rollover is mostly affected when trading on Daily timeframe, so there's practically no chance that the entry rules changes in 20 or even 60 minutes. So if the price is reasonable the trade should be executed.


For lower timeframes, for example, M15, the chance of getting an entry at 00:00 is very small compared to trading on Daily timeframes. But it will happen indeed, so it would be wise to check if the entry rules are still met.


When OrderSend receives error 132 it means market is closed and it is a possible rollover.
The following code confirms if it is a rollover:

if(err == 132 && DayOfWeek() != 6 && Hour() == 0 && Minute() <= 30)

Hope this helps.

4 (edited by Finmod123 2019-09-27 18:46:54)

Re: Suspend and delay signals when market is off around midnight

When do you plan to implement this feature?

I think such code before all ordersend, orderclose, ordermodify can work:
if (Hour() == XX && (Minute() >= Y1 && Minute()<=Y2)) Sleep((Y2-Minute())*1000);
where market is closed at XX hours between Y1 and Y2 minutes

Re: Suspend and delay signals when market is off around midnight

Sleep, may not work well because it effectively suspends the complete expert.

I think fo saving the signal's details and re-sending in particular time interval.

The idea of eacoder of checking the price shift is very good for the robustness of the expert.

Re: Suspend and delay signals when market is off around midnight

Did this ever receive an implementation? I encountered the issue tonight where trades weren't opened during rollover

Re: Suspend and delay signals when market is off around midnight

Arc wrote:

Did this ever receive an implementation? I encountered the issue tonight where trades weren't opened during rollover

I am having the same issue

Re: Suspend and delay signals when market is off around midnight

hi
when i check the jornal i see that the strategy opens a long position at 00.05 but in real live acc at 00.5 opens a short is the problem is related to this topic?
how to solve it?

Re: Suspend and delay signals when market is off around midnight

can we use the spread pro andicator ? do not enter a position when the spread is above the 22 for example...
then the position wont be open at midnight...
but still there is a problem and that is when you set the spread in symbol details at 22 the FSB app think that the spread is always at 22 .

Re: Suspend and delay signals when market is off around midnight

Popov wrote:

Hello traders,

I want to add a fix in the EA's code to work around the problem with the brokers that suspend the trading around midnight for swap calculations.

The problem appears when we trade mostly on D1, H4, or H1 charts and the strategy has a signal at 00:00 but the market is off.

A possible solution is to "remember" the signals and execute it when the market is open.

We have to add some limitations for how long the signal can be delayed.

A possible workflow is:
- save the signal if the market is closed
- periodically check if the market is open (let's say every 15 seconds)
- send the order if the market is open.
- cancel the signal if the market is closed for longer than N minutes. Log a message.

I also want to have a predefined time for this procedure. Let's say:


We can add these options in the EA Studio's Settings. Something like that:
  [ V ] Enable signal delay on Market Closed
            Expected Market Closed time start:  23:55
            Expected Market Closed time end:   00:05
            Maximum time for signal delay in minutes: 2.0
            Retry interval in seconds: 15

Please share your opinion.

If you have a working code, please share it. It will help us to come with a faster and more stable solution.

did you have implemented this?