Mt4 End of support. - page 31

 
Vladimir Pastushak:

4 cycles isn't that cool ? at 600 characters in the market overview every minute the terminal will die ....

What are you talking about? The timer cycles 1 time per minute. That's nothing at all.

And the user accesses the New_bar() function whenever he wants.

 
Alexey Viktorov:
As far as the code comment is concerned: What if we need to define the opening of only the current period and only one character at a time in the program? Will this whole construct be spinning all the loops? It would be irrational.

Completely misunderstood the code.

New symbol bar events are captured in a loop once a minute. Automatically. If the current number of bars is not equal to the number of bars recorded in the array, we set the flag of a new bar event in the array Events_new_bar[][].

 

Alexey Viktorov:


ps; And why start a millisecond timer? Isn't a second timer enough?

You can also set a second timer. Then write "Timer_frequency = 1000".

 

I put it in, tested it, it doesn't work.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(Новый_бар(Symbol(), PERIOD_M1)) Print("M1 = ",Time[0]);
   if(Новый_бар("EURUSD", PERIOD_M5)) Print("M5 = ",Time[0]);
  }
Always gives out false
 
Vladimir Pastushak:

Isn't 4 cycles cool ? at 600 characters in market overview every minute the terminal will die ....

I wonder if anyone really has that many ?

I have 16 - and I'm already wondering if the load is too much ?

True, I have a minimum timeframe of M15... But still, I wonder when the load on the terminal starts to be critical ?

 
Реter Konow:

What do you mean? The timer cycles once per minute. That's nothing at all.

And New_bar() is called whenever the user wants.


The "new bar" function is usually executed on every tick... This call on every tick is done to save resources. Realise how your function "saves" resources, it eats them up.

 
George Merts:
... But still, I wonder when the load on the terminal starts to be critical ?

When the processor gets into its knees and can't get up.

Respectfully.

 
Реter Konow:

Completely misunderstood the code.

New symbol bar events are captured in a loop once per minute. Automatically. If the current number of bars is not equal to the one recorded in the array, we set the flag of the new bar event in the array Events_new_bar[][].

Let's discuss another example of using OOP.

Forum on Trading, Automated Trading Systems and Strategy Testing

Mt4 End of support.

Alexey Viktorov, 2017.09.11 13:08

I think I've found a primitive example of the usability of OOP. Here's a function to fill an array with a specified value. There are eight varieties depending on array type.

Imagine you need to write a function that needs to pass one set of parameters, then another, then a third... Using algorithmic approach you'll get N different function's names. It would seem that there is nothing wrong, you can write 8 such functions as ArrayInitializeInt()ArrayInitializeDouble() and so on. But it's nice not to think about the type of array, just use one function in any case, and how safe it is to mix up which array you put there...


Документация по MQL5: Операции с массивами / ArrayInitialize
Документация по MQL5: Операции с массивами / ArrayInitialize
  • www.mql5.com
Операции с массивами / ArrayInitialize - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vitaly Muzichenko:

Installed, tested, does not work

It always outputs false.

1. Run the EA on M1.

2. Need to wait until current bar is completely finished. At the first bar, the event is not fixed. I did it on purpose. Next you need to wait as long as the timeframe that you are sending to the function suggests.

I tried it on a minute and it worked.

 
Dmitry Fedoseev:

The "new bar" function is normally executed on every tick... This call on every tick is done to save resources. Realise how your function "saves" resources, it eats them up.

You obviously don't know how to read codes. )) Where does it gobble them up?