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

 
darirunu1:

Are you visually impaired?

What's with the horse text?

 
Сергей Таболин:

Are you visually impaired?

What's with the horse text?

An accident.

 
Alexey Viktorov:

What if a person writes for himself or herself?

It's not like he can measure the distance from an invisible point anyway, the intersection will be somewhere else.

 
Taras Slobodyanik:

It will not measure the distance from an invisible point anyway, the intersection will be in a different place.

I was saying that if a person is writing for himself, he understands what he is doing and understands what will happen.

This is the forum for trading, automated trading systems and strategy testing.

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

Taras Slobodyanik, 2021.02.28 09:37

If you do not know how to check the correctness of deals, they will hang in the air, and the user will say - MT4 is a glitchy one)


And it is precisely to measure from an invisible point that you need to put this value into a variable.
 
Alexey Viktorov:

I was saying that if one writes for oneself, one understands what one is doing and understands what will happen and will not say


And just to measure from an invisible point, you need to put this value into a variable.

that's how Grails are born)

then not into a variable, but into a buffer, because there will be a lot of such points.

 
Look at what you get in the end. Bottom indicator, I didn't touch native code, I just played with parameters. I changed zero bar to the first bar in the price chart in the code of the indicator.
 
Alexey Viktorov:

At the moment of crossing, the value of the MA was not the same as it became after the bar was closed. Therefore, this value can only be found at the moment of crossing.

//+------------------------------------------------------------------+
//|                                                         Test.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//---

double     FixPrice;        // переменная
bool       Fix = false;      // маркер
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(Fix == false)
     {
      if(Close[0] > MA_lo)
         FixPrice = Close[0];
     }                                                                              // делаем замер пока цена не пересечет МА
   if(Close[0] < MA_lo)
      Fix = true;
   if(Fix == true)
      FixPrice_L = FixPrice ;
//+------------------------------------------------------------------+
  }
//+------------------------------------------------------------------+

It is how you want the value to be memorized.

But keep in mind that

Close[0]=Open[0] 
и Close[0]=High [0] и Close[0]=Low[0]


at the opening of a candle.

Therefore, if you need instantaneous, real-time data, you'd better use

double Bidd=NormalizeDouble(Bid,Digits); если цена сверху или
double Askk=NormalizeDouble(Askk,Digits); если цена снизу МА

double MA_lo=NormalizeDouble(MA_lo,Digits);

It's better to normalize all prices to be compared in the condition, so you won't be surprised :)

Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • 2021.02.28
  • www.mql5.com
MQL5: язык торговых стратегий для MetaTrader 5, позволяет писать собственные торговые роботы, технические индикаторы, скрипты и библиотеки функций
 
Александр:

It's how you want the value to be remembered.

But keep in mind that

at the opening of a candle.

So if you want instantaneous, real time, it's better to use

It's better to normalise all prices to be compared in the condition, so you won't be surprised :)

Good heavens! Did I want something? Did I ask for anything? Who do you think I am?
 

Hello all!
When writing code to test an EA, I need to search for the low in real time inside each minute candlestick. To do this, I chose a predefined variable Low[0] with index 0. The index is zero to search for the low in each current candle.

Here is my code
void OnTick()

{

Print("------------", Low[0] );

}

On the first (yellow) candlestick, the variable shows the minimum as I need it to

On all subsequent candlesticks until 2010.01.04 00:30:00 the variable shows -1.6119, i.e. it repeats the minimum of the first candle, rather than looking for minima on every single minute candle.
On the candlestick 2010.01.04 00:30:00 it shows every minimum again

On the next candle after this one it shows -1.6128 , i.e. it repeats the minimum of the first candle instead of looking for lows inside each one-minute cand le.

Instead of Low[0] variable I used the same function iLow(NULL , 0,0) , but the effect was the same.
QUESTION
How to use the mentioned function or variable to search for a minimum in every minute candle, or what other function is it possible to use in MQL4?

Thank you all for your help.

Документация по MQL5: Предопределенные переменные
Документация по MQL5: Предопределенные переменные
  • www.mql5.com
Предопределенные переменные - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
iLow(NULL,1,0)