Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1427

 
MrBrooklin #:

Hello, Valery! I completely agree with you. To write a correct code, you need an exact condition for opening a position. This code works too:

but the whole question is whether it should work as Vitaly intended? Frankly speaking, I don't quite understand why once every 20 seconds (or even once every 10, 5 or 1 second), we need to check the price difference. What will it do in terms of determining the direction of further price movement?

Regards, Vladimir.

MrBrooklin #:

Hello, Valery! I completely agree with you. To write a correct code, you need an exact condition for opening a position. This code works too:

but the whole question is whether it should work as Vitaly intended? Frankly speaking, I don't quite understand why once every 20 seconds (or even once every 10, 5 or 1 second), we need to check the price difference. What will it do in terms of determining the direction of further price movement?

Regards, Vladimir.

You describe the task incorrectly! It is not "once every 20 seconds", but to check every second with the indicators that have passed some time ago. As for "why" - this is not a question for this discussion. (And 20 seconds is just as an example).

It's like a moving average, where the first candle is compared to the second candle. Only I have to calculate everything inside the current (zero) minute candle. (Or even better - on a line chart. After all, 20 seconds can flow to the first candle).

 
vitaliy zamkovoy #:
You are not describing the task correctly! It is not "once every 20 seconds", but every second to check the values that have passed some time ago. As for "why" - this is not a question for this discussion. (And 20 seconds is just as an example).

Yes, my mistake, I didn't fully understand what you want to do/check.

Regards, Vladimir.

 

But if the distance equal to your constant is travelled not in any even number of seconds, but for example in 10.964 seconds or 11.283 seconds, what happens then? Will the condition be fulfilled or not?

Regards, Vladimir.

 
MrBrooklin #:

But if the distance equal to your constant is travelled not in any even number of seconds, but for example, in 10.964 seconds or in 11.283 seconds, then what happens? Will the condition be fulfilled or not?

Regards, Vladimir.

In the term "comparison with a constant" I do not mean equality, but "more" "less". In case of positive difference we compare with the constant with + sign, and in case of negative difference we compare with the constant with " - " sign. If in the first case we exceed the constant, we buy. In the second case, if the value is less - sale.
 
vitaliy zamkovoy #:
In the term "comparison with a constant" I do not mean equality, but "more" "less".

Now everything is clear.

Regards, Vladimir.

 
MrBrooklin #:

Now it all makes sense.

Regards, Vladimir.

I have updated the messages there. Please re-read them.
 

I am so sick of reading all this nonsense... After all, the code is only FOUR lines, and the discussions are 3 pages long.

  MqlTick mqlTick[], symbTick; // объявили переменные
  SymbolInfoTick(_Symbol, symbTick); // это последний тик
  CopyTicksRange(_Symbol, mqlTick, COPY_TICKS_ALL, symbTick.time_msc, symbTick.time_msc-20000); // Получили все тики за последние 20 секунд
  double delta = NormalizeDouble(mqlTick[ArraySize(mqlTick)-1].bid-mqlTick[0].bid, _Digits); // получили разницу крайних значений массива

20,000 milliseconds is 20 seconds.

Next, put a condition on the size of the delta variable more/smaller, left/right or north/yuh....

 
MrBrooklin #:

Now it all makes sense.

Regards, Vladimir.

MrBrooklin #:

Now it all makes sense.

Regards, Vladimir.

vitaliy zamkovoy #:
I have updated the messages there. Please re-read them.
Alexey Viktorov is a snob, but realised the trick at once. 😆
 
vitaliy zamkovoy #:
In the term "comparison with a constant" I do not mean equality, but "more" "less". If the difference is positive, we compare it with a constant with a + sign, and if the difference is negative, we compare it with a constant with a - sign. If in the first case we exceed the constant, we buy. In the second case, if the value is less - sale.

Now everything is clear.

Regards, Vladimir.

P.S. The only thing I can recommend is to watch my message here for the sake of interest. And then look how the price behaved after this message. It rolled back to 0.98000, or more precisely to 0.9806, and then went up again, as shown by the red arrow on the screenshot of the price chart. This recommendation is just for your reflection.

 
vitaliy zamkovoy #:
Alexei Viktorov is a snob, but he got it right away. 😆

Vitaly, you don't know a person, but you are already trying to judge him. It's very incorrect of you. Every man has his own principles. That's it, end of story!

With respect, Vladimir.

Reason: