Mt4 End of support. - page 18

 
Artyom Trishkin:

The task is as follows: I need to make a function that will return the fact of opening a new bar. First on EURUSD M5.

Further the task will be extended.

I see.

Suppose the following function prototype will work: bool New_bar(int Timeframe = M1) ?

It means that a user calls the function and sends the ID of the desired timeframe to it. In response he gets true/false (a new bar opened or not)?

If this is what is needed, I will try to write it now.

 
Alexey Viktorov:

I see. Got the wrong guy... You know how to pass a variable by reference, no doubt.

Now, for simplicity of writing in the code, if you need to determine the specified period and the current period. It turns out that you have to create variables for the current period as well, right?

Wait a minute, I'm figuring out the problem statement.
 
Реter Konow:

I see.

Suppose this prototype function would work: bool New_bar(int Timeframe = M1) ?

That is, a user calls the function and passes to it the identifier of the desired timeframe. In response he gets true/false (a new bar opened or not)?

If that's what's needed, I'll try writing it now.

Just need to write a function that asks the user: "is there a new bar on M5?" and gets a yes/no answer.

For example:

if(IsNewBar(PERIOD_M5)) // Вопрос: наступил ли новый бар на М5
  {
   // Да, наступил
  }
else
  {
   // Нет, не наступил
  }

Here is your function IsNewBar() and we will develop and twist/rotate it further with further extension of the task

 
Artyom Trishkin:

You just need to write a function where the user asks: "is there a new bar on the M5?" and gets a yes/no answer.

For example:

Here is your function IsNewBar() and we will develop and twist/rotate it further with a further extension of the task

I see. Ok. Give me some time and I will draw up the code. Only in Russian. I will make it more convenient.
 
Реter Konow:

I see.

Suppose this prototype function would work: bool New_bar(int Timeframe = M1) ?

That is, a user calls the function and passes to it the identifier of the desired timeframe. In response he gets true/false (a new bar opened or not)?

If this is what you need, I'll try to write it now.

A tip from a self-taught trainee:

To ease the migration to mql5, it would be better to use not int period variables in mql4, but from the enum ENUM_TIMEFRAMES.

 
Реter Konow:
Got it. Good. Give me some time, I'll write up the code. Only in Russian. It's more familiar.

Even better. It's easier for Russians and Russian speakers to understand.

 
George Merts:

... Inheritance and polymorphism...


I gladly believe that your problems cannot be solved without them. You have to go into details to believe it :)


Artyom Trishkin:

You just need to write a function that asks the user: "is there a new bar on M5?" and get a yes/no answer.

For example:

Here is your function IsNewBar() and we will develop and twist/rotate it further with further extension of the task

Spin

bool fb_Is_New_Bar(ENUM_TIMEFRAMES e_TF) {
  int
    i_This_Bar = int(floor(TimeCurrent() / PeriodSeconds(e_TF))),
    i_Last_Bar = int(GlobalVariableGet("LastBar " + string(e_TF)))
  ;
  if(i_This_Bar == i_Last_Bar) return(false);
  
  GlobalVariableSet("LastBar " + string(e_TF), i_This_Bar);
  return(true);
}
 

this is going to be a bit of an off-topic to the conversation.

I was just peeling potatoes and a thought occurred to me

if there are developers and programmers here, why not do it on µl


- a self-sufficient file with its own interface that runs the terminal, skype and another terminal

- on the mt4(5) terminal putting a bot from a selected list of 3 (drop-down menu)

 
Alexander Puzanov:

...

Spin


Spin it. Terrible brakes.

 
Mickey Moose:

this is going to be a bit of an off-topic to the conversation.

I was just peeling potatoes and a thought occurred to me

if there are developers and programmers here, why not do it on µl


- a self-sufficient file with its own interface that runs the terminal, skype and another terminal

- on the MT4(5) terminal put a bot from a list of 3 selected (drop-down menu)


Why?