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

 
Vladislav Andruschenko:


checked.

In MT4 - OnStart works in the indicator!


indicator is not unloaded


In MT5 - OnStart is not executed in the indicator!



So it's more of an omission that it's not banned in mt4.

Everything is executed there... before I say something, I double-check it. Because new releases bring many surprises :-)

--

"create an indicator" ... blah, blah, blah... Leave the OnStart() function

 
Maxim Kuznetsov:

Everything is fulfilled there... before I say anything, I double-check. Because new releases bring many surprises :-)

--

"create an indicator" ... blah, blah, blah... Leave the OnStart() function


just leave it?


well just checked. it's not executable in mt5. build flatt 2940

Or have you removed OnCalculate?



aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :-) created a script and put it in the indicators folder

#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void OnStart()
  {
   Print ("GG OnStart");
  }

Unique.

More like an exception, you just stuck the script in the indicators folder and the terminal gobbled it up.

 

Good afternoon all!

I am writing code for the tester on 1 minute TF in mql4, the model is all ticks.

Could you please tell me how to save the minimum of the last hour candle in a variable as quickly as possible for the following code

datetime some_time;
void OnTick()
{
if (Bid - iLow( NULL ,PERIOD_H1,1)>=0.0030)
some_time = (время образования iLow( NULL ,PERIOD_H1,1))
}


Thank you.

 
ANDREY:

Good afternoon all!

I am writing code for the tester on 1 minute TF in mql4, the model is all ticks.

Could you please tell me how to save the minimum of the last hour candle in a variable as quickly as possible for the following code


Thank you.

some_time = iTime( NULL ,PERIOD_H1,1);
 
ANDREY:

Good afternoon all!

I am writing code for the tester on 1 minute TF in mql4, the model is all ticks.

Could you please tell me how to save the minimum of the last hour candle in a variable as quickly as possible for the following code


Thank you.

datetime some_time;
void OnTick()
{
   if (Bid - iLow( NULL ,PERIOD_H1,1)>=0.0030)
      some_time = TimeCurrent();
}
 
PapaYozh:
Wrong, it needs the time of the previous candle
 

Yes, I was inattentive.

But minimum formation time can only be obtained by tracking incoming quotes in real time.

I.e. you still have to keep track of the time of formation of the minimum of the 0th candle and, when it becomes the 1st, use it in the code.

What you suggested will return the start time of the candle, not the time of the low.

PS.

There seems to be a mistake initially in that the Bid is compared to the Low of the 1st candle. The Bid has nothing to do with the 1st candle.

I guess it should be like this:

datetime some_time;
void OnTick()
{
   if (Bid - iLow( NULL ,PERIOD_H1,0)>=0.0030)
      some_time = TimeCurrent();
}
 
PapaYozh:

Yes, I was inattentive.

But the time of minimum can only be obtained by tracking incoming quotes in real time.

I.e. we still have to keep track of the minimum time of the 0th candle and use it in the code when it becomes the 1st.

What you suggest will return the time of the candle's start, not the time of its minimum.

That's what I'm talking about, if you want the time of formation of the minimum, then you should do it like this

datetime some_time;
void OnTick()
{
   if (Bid - iLow( NULL ,PERIOD_H1,0)>=0.0030)
      some_time = TimeCurrent();
}
 
MakarFX:

That's what I'm saying, if you need a minimum education time, it's like this

Thank you.

 
ANDREY:

Thank you. I think the most correct answer isPapaYozh's"..... But the time of minimum can only be obtained by monitoring the incoming quotes in real time.

So you still have to keep track of the time of the minimum of the 0th candle and use it in code...... when it becomes the 1st"
I knew what he said, but I thought there is a way to get the minimum of hourly candle N1 without tracking each incoming quote, and each minimum of minute candle.

In this case some_time will be equal to the opening time of the current candle... PapaYozh will confirm.

Reason: