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

 
Boris:

So... Read the documentation (again).

Question. What is wrong? It doesn't count neither with CopyTicksRange nor with CopyTicks.

You have to read more and more and more... Read it until you read what I copied from the documentation for you personally and marked it in bold red font.

What a nuisance... citations are not clinging... I`ll have to duplicate them...

from_msc

[in] The date from which the ticks are requested. Specified in milliseconds from 01.01.1970. If thefrom_msc parameter is not specified, then the ticks are returned from the beginning of the history. Ticks with time >= from_msc are returned.

to_msc

[in] Date, on which the ticks are requested. Specified in milliseconds from 01.01.1970. Ticks with time <= to_msc are returned. If parameterto_msc is not specified, all ticks until the end of the history are given .


 
Boris:

So... Read the documentation (again).

Question. What is wrong? It doesn't count neither through CopyTicksRange nor through CopyTicks.

The question I have, for example, I don't know µl5 well, is the word Date, not Time. And accordingly a question, and within one date what age will be?

And after a hint. How to get the time in milliseconds?

 
Valeriy Yastremskiy:

The question I have is, for example, I don't know µl5 very well, it's the word Date, not Time. And accordingly the question is, within the same date, what is the age?

And after a hint. How to get the time in milliseconds?

1 second = 1000 milliseconds. And "Date" implies "Date and Time", because the type is datetime and not just date.

 
Alexey Viktorov:

Read more and more and more... Read until you've read what I've personally copied from the documentation for you and highlighted in bold red.

Shame... the quotes don't stick... I'll have to duplicate them...


Oh, man... Yeah, well... It's working!

 

QUESTION on mql4:

There is a spread restriction in the EA's code, the EA is set for several charts.

It is not quite correct to enter the average spread for a pair into the input parameters, and it varies from one dealing desk to another.

The average spread is 5pp, but there are moments when it widens to 12pp for a few minutes and it's not a rollover.

How can I automate this in order to calculate the average spread and not to open a position on an extended spread?

   MqlRates rates[]; 
   int copied=CopyRates(NULL,PERIOD_M1,0,100,rates); 
   if(copied>0) 
   for(int e = ArraySize(rates)-1; e >=0; e--) {
     Print(e,"=",rates[e].spread); // всегда "0"
   }
 

Hello, is it possible and how to create an Expert Advisor based on the algorithm of opening and closing a deal without using any indicators?

For example, take two lines, one trend line is up and the second is also down, put them on top of each other, there is a point of intersection between the two lines, let's assume it is at 15-30 in time, then how to make the order automatically opened at the same time to start in any direction, how to make the algorithm will find these points andopen a position? I would like clarification and your opinions.

Can we create an EA based on such T3?
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением...
 
Vitaly Muzichenko:

QUESTION on mql4:

There is a spread restriction in the EA's code, the EA is set for several charts.

It is not quite correct to enter the average spread for a pair into the input parameters, and it varies from one dealing desk to another.

The average spread is 5pp, but there are moments when it widens to 12pp for a few minutes and it's not a rollover.

How to automate this in order to calculate the average spread and not to open a position on the wider spread?

A good idea is to watch the spread on every tick. Judging by the rhetoric and traders' problems with its sharp increase to loos. The problem, as I understand it, is not a long large spread, that's the least of the problems, but a sharp large and short spread increase.

I would look at the one specified in the symbol properties, take it as an average and reasonably increase it before opening orders. And we would also look at the spread to close or modify it. Or, I would monitor the average spread on the last 3 to 10 ticks.

 
Valeriy Yastremskiy:

A good idea is to watch the spread on every tick. Judging by the rhetoric and traders' problems with its sharp increase to loos. The problem, as I understand it, is not a long large spread, that is the least of the problems, but a sharp large and short increase in spread.

I would look at the one specified in the symbol properties, take it as an average and reasonably increase it before opening orders. And we would also look at the spread to close or modify it. Or, the spread on the last 3 to 10 ticks would be monitored on average.

Yesterday about 1 minute (and it's not 10 ticks) there was ~14 points spread with an average normal spread of 4 points. So at the moment of extended spread the robot went in to buy.

10 ticks is clearly not enough

 
Vitaly Muzichenko:

Yesterday for about 1 minute (which is not 10 ticks) there was ~14pp spread with an average normal spread of 4pp. So at the moment of extended spread the robot went in to buy.

10 ticks is obviously not enough.

The task here is to fix the beginning and the end of changes. And the fixation should be made in a short time interval. I.e., the average value of spread should be fixed from a second to 10 seconds by a floating window. You should watch how many ticks per second on average or watch the ticks for 10 seconds and average. I prefer the first option.

 
Valeriy Yastremskiy:

The task here is to capture the start of changes and the end. and the emissions of single changes. and the capture must be in a short period of time. The average value of the spread should be fixed from a second to 10 seconds by a floating window. You should watch how many ticks per second on average or watch the ticks for 10 seconds and average. The first variant is closer to me.

I have solved it that way:

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

   if(CheckSpr(sp)) {
     // Здесь код отправки
   }
}

//+------------------------------------------------------------------+
bool CheckSpr(int _sp)
{
  static int ts=0, res=0;
  static long tc=0;
   tc++;
   ts += _sp;
   res =ts/tc;
   if(tc>LONG_MAX-1) {
      tc=0;
      ts=0;
   }
   // Comment( res,"=",tc );
   if(tc<500) return(false);
   return(res>_sp?true:false);
}

The problem is that it will record a huge spread in the rollover and will work with it.

I think this solution is ineffective, we need to somehow limit the recording at rollover without applying a time limit.

Reason: