Mt4 End of support. - page 44

 
Реter Konow:

Now tell me - have I completed the task?

You (Peter and opponents alike) are coming at it from the wrong side! The task can be done both ways !

An assembler will come along and say that he can do it even more effectively, and with even less consumption of computer resources !

But what's the sense in it?

In my opinion, we should think about efficiency only when we are short of speed or memory. When you have enough of it, it is more important that it is easy to maintain and modify the system. Even if it takes some detriment to speed of program and memory used.

Russian names do not bother me, the only thing that bothers me - I'm used to prefixes, so that you can immediately understand the type of variable by its appearance. And Russian or English identifier - the difference is not great (1C - there is a lot of Russian).

But most of all I'm surprised by voluntary refusal of a debugger. It's just masochism... I can understand when there's no debugger (at one time there was no debugging on historical data) - you have to twist, issue debug messages, logs... But if you have a debugger - it is much more convenient and efficient to work with it !

 
George Merts:

You (Peter and opponents alike) are coming at it from the wrong side! The task can be done both ways !

An assembler will come along and say that he can do it even more effectively, and with even less consumption of computer resources !

But what's the sense in it?

In my opinion, we should think about efficiency only when we are short of speed or memory. When you have enough of it, it is more important that it is easy to maintain and modify the system. Even if it takes some detriment to speed of program and memory used.

Russian names do not bother me, the only thing that bothers me - I'm used to prefixes, so that you can immediately understand the type of variable by its appearance. And Russian or English identifier - the difference is not great (1C - there is a lot of Russian).

But most of all I'm surprised by voluntary refusal of a debugger. It's just masochism... I can understand when there's no debugger (at one time there was no debugging on historical data) - you have to twist, issue debug messages, logs... But if you have a debugger - it's much more convenient and efficient to work with it !

George, I had no idea how to use a debugger. Didn't even know or wonder what it was for. So there's no masochism here. And now it's too late.
 

Peter, you have substituted the task. Your solution is sometimes needed, but very rarely, and not purely in this form, but similar.

More often a different task - appearance of new bars should be tracked in different places of the program. Therefore, passing a symbol and a timeframe into functions and searching for them in arrays is not a good solution at all. Since the isNewBar function has a static variable, we have to make a copy of the function for each timeframe symbol. It is possible to pass a variable for the last timeframe into the function by reference.

But there is an ideal variant with OOP - it creates its own object for each symbol - timeframe.

This is, if we do not consider that the isNewBar function is not needed at all, just to stereotype from nothing to do.

 
Dmitry Fedoseev:

Peter, you have substituted the task. Your solution is sometimes needed, but very rarely, and not purely in this form, but similar.

More often a different task - appearance of new bars should be tracked in different places of the program. Therefore, passing a symbol and a timeframe into functions and searching for them in arrays is not a good solution at all. Since the isNewBar function has a static variable, we have to make a copy of the function for each timeframe symbol. It is possible to pass a variable for the last timeframe into the function by reference.

But there is an ideal variant with OOP - it creates its own object for each symbol - timeframe.

That is, if we do not consider that the isNewBar function is not needed at all, it is purely to rubbish, from nothing to do.

I haven't changed anything. I just solved this task in a different way. Following your logic, I must have inevitably come to the necessity of OOP. However, no matter how you look at it, you can safely use my solution. Any function, at any time and from any place in the program accesses the global array for a new bar event on any symbol and any timeframe.

It doesn't matter how many symbols and how many timeframes there are - in my solution their number doesn't increase the load on the system. Just look at the array - whether there is a new bar event or not.

You can reduce the list of symbols if you do not take them from the market report but type them manually in the Symbols[] array. Please.


Added:

By the way, please note - the New_bar() function is no longer there. It has really turned out to be unnecessary. You were right.

 
Реter Konow:

I was tasked with: making it so that I could get new bar events of a set of symbols, on a set of timeframes, without OOP, and that it would be short and efficient code.

Now tell me - have I completed the task?

Absolutely YES. But!!! As it happens, my suggestion was twisted a bit and as a result you understood it as you understood it. In forex, you are only interested in data that you need here and now. I need the information for one symbol and for the current period, that's all - the other ones do not interest me. We need the information for another symbol and a certain period, then the same code should get it. And there is no need to overload the system with receiving information, which is not needed now.

It's not your fault, it just happened. I tried to stop you, but I couldn't.

 
Dmitry Fedoseev:

Peter, you have substituted the task.

He didn't switch it up. It was the way the sentence was paraphrased that he understood it that way.

 
Alexey Viktorov:

Absolutely YES. But!!! As it happens, my suggestion has been twisted a bit and as a result you have understood as you have understood it. In forex, you are only interested in the data you need here and now. I need the information about one symbol and the current period, that's all - the other ones do not interest me. We need the information for another symbol and a certain period, then the same code should get it. And there is no need to overload the system with receiving information, which is not necessary now.

It's not your fault, it just happened that way. I tried to stop you, but I couldn't.

No problem, you just write names of needed symbols into Symbols[] array.

Remove record from OnInit():

   for(int a1 = 0; a1 < All_symbols; a1++)
     {
      Symbols[a1] = SymbolName(a1 + 1,true); 
      //Возможно, нумерация символов в обзора рынка идет с нуля.
      //Тогда: Symbols[a1] = SymbolName(a1,true);
     }

And initialize array in global scope:

Symbols[3] = {"EURUSD","AUDUSD","GBPUSD"};

And remove unnecessary timeframes from Timeframes[] array;

int    Timeframes[3] = {PERIOD_M1,PERIOD_M5,PERIOD_M15};

Change the variable.

int    All_Timeframes = 3;

And change the All_Symbols variable:

int    All_symbols = 3;

This way you will receive events only for the right symbols and the right timeframes.

Added:

Also remove the array size setting from OnInit(), since you know the number of symbols:

   //-------------------------------------------------------------   
   All_symbols = SymbolsTotal(true);
   //---------------------------------------------------------   
   ArrayResize(Symbols,All_symbols);
   //---------------------------------------------------------
   ArrayResize(All_bars_table,All_symbols);
   //---------------------------------------------------------
 
Реter Konow:

I didn't substitute anything. I just solved this problem differently. Following your logic, I inevitably had to come to the need for OOP. However, no matter how you look at it, you can safely use my solution. Any function, at any time and from any place in the program accesses the global array for a new bar event on any symbol and any timeframe.

It doesn't matter how many symbols and how many timeframes there are - in my solution their number doesn't increase the load on the system. Just look at the array - whether there is a new bar event or not.

You can reduce the list of symbols if you do not take them from the market report but type them manually in the Symbols[] array. Please.


Added:

By the way, notice - the New_bar() function is gone. It really turned out to be unnecessary. You were right.


If so, as highlighted in bold - in the bin.

 
Dmitry Fedoseev:

If as highlighted in bold, it goes in the bin.

Why?
 
Реter Konow:

No problem, just write in the Symbols[] array the names of the symbols you want and you're done.

Remove entry from OnInit():

And initialize array in global scope:

And remove unnecessary timeframes from Timeframes[] array;

Change the variable

And change All_Symbols variable:

This way you will receive events only for needed symbols and needed timeframes.


Peter, stop it. I don't need any other function to define a new bar other than my own. Well it just so happens that all your hard work has become unnecessary, sorry.