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

 
Vitaly Muzichenko:

All of the above does the code, except for the yellow highlighted - I think it's unnecessary and not quite correct. I've never seen anyone rollover at a different time, always at the same time - 22-00 GMT, although I could be wrong.

But often seen different duration rollover, some 5 minutes, and others a little over a minute.

---

Check code, maybe change something:

So and tie everything to GMT time. Got the difference of local time and server time, and you can immediately understand in how many rollover. And 5 minutes or 1 I think there is no significant difference. Take 5 minutes for all.

 
Alexey Viktorov:

So, tie everything to GMT time. Get the difference between local time and server time, and you can immediately understand how long the rollover is. And 5 minutes or 1 I don't think there's much difference. Take 5 minutes for all.

How is your option better or more reliable?

If you can, show me the code!
 
Vitaly Muzichenko:

How is yours better, or more reliable?

Maybe not at all. I didn't follow your codes. Just giving my opinion.

 

Vitaly Muzichenko:

If you can, show me the code!

Are you pretending?

 
Alexey Viktorov:

Maybe it's nothing. I haven't been following your codes. Just giving my opinion.

Here's everything in one post:

You need to screen out the spread entry during the rollover so that the EA doesn't trade on the extended spread.

Forum on trading, automated trading systems and strategy testing

Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes

Vitaly Muzichenko, 2021.02.11 14:04

I have never encountered such a code before. Somehow never seen that rollover was someone at a different time, always all in one and the same - at 22-00 GMT, although I can be wrong.

But often seen different duration rollover, some 5 minutes, and others a little over a minute.

---

Check code, maybe change something:

//+------------------------------------------------------------------+
void OnTick(void)
{
   int sp = SymbolInfoInteger(Symbol(),SYMBOL_SPREAD);
   static int ts=0;

   if(CheckSpr(sp)) {
      // Здесь код отправки
      Comment( sp,"=",ts++,"=",res );
   } else Comment( "false: ",sp,"=",ts++,"=",res );
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
MqlDateTime dt;
int res=0;
bool CheckSpr(int _sp)
{
  TimeGMT(dt);
  static int ts=0;
  static long tc=0;
   if(dt.hour==22) return(false); // ролловер
   tc++;
   ts += _sp;
   res =ts/tc;
   if(tc>LONG_MAX-1) {
      tc=0;
      ts=0;
   }
   // Comment( res,"=",tc );
   if(tc<500) return(false); // собираем спред на 500 тиках
   return(res>_sp?true:false);
}

 
Vitaly Muzichenko:

Here's everything in one message:

We need to weed out the spread entry during the rollover so that the EA doesn't trade on the extended spread.


No trading during a full hour?

   if(dt.hour==22) return(false); // ролловер

Or did you misunderstand something?

 
Vitaly Muzichenko:

Here's everything in one message:

We need to screen the spread entry during the rollover, so that the EA doesn't trade on the extended spread.


are we just hypothetically prohibiting some kind of spread record (file, database) specifically in the rollover?

 
Alexey Viktorov:

No trade for a whole hour?

Or did you misunderstand something?

That's right, for a full hour afterwards, the spread is widened. And before the rollover in 5 minutes it is widened in some places as well.

 
Alexey Viktorov:

No trade for a whole hour?

Or did I misunderstand something?

However, it can be set like this:

void OnTick(void)
{
   int sp = SymbolInfoInteger(Symbol(),SYMBOL_SPREAD);

   if(CheckSpr(sp)) {
      // Здесь код отправки
      Comment( sp,"=",res );
   } else Comment( "false: ",sp,"=",res );
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
MqlDateTime dt;
int res=0;
bool CheckSpr(int _sp)
{
  static int ts=0;
  static long tc=0;
  TimeGMT(dt);
   if(dt.hour==22 && res<_sp) return(false); // Если 1 час после ролловера спред упадёт до нормального - торгуем
   tc++;
   ts += _sp;
   res =ts/tc;
   if(tc>LONG_MAX-1) {
      tc=0;
      ts=0;
   }
   if(tc<500) return(false);
   return(res>_sp?true:false);
}

This should work correctly.

 
Vitaly Muzichenko:

You could, however, prescribe it this way:

That should work.

Funny) It shouldn't)

If the battle is for - trade with a normal spread, just put its "limit" in input and just ignore the trade if the spread is above the limit.

Spreads can be stretched by dillings without rollover.