Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1177
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
First, about the bars. When a new bar is formed, a new value is written to Time[0] - the time when the bar opens.
OnCalculate(...)
{
if(Time[0] == t) return(0); // If this bar is processed --> exit
t = Time[0];
Now for the whole history: it will slow
datetime t;
First, about the bars. When we form a new bar, we write a new value into Time[0] - the time when the bar opens.
OnCalculate(...)
{
if(Time[0] == t) return(0); // if this bar is processed --> exit
t = Time[0];
Now for the whole story: it will slow down
Thanks for the quick reply. What I'm asking is how to make it NOT slow down and run through history when a new bar appears, but just process the new bar...
Now it's organized as follows: for(int i=limit-1; i>=0; i--) and as I understand it, it means that at every opening of a bar, all values on the entire history will be recalculated again, while you should work only with the last bar...
This is how it calculates on the last bar:
Let's look at the line first
to make it clearer to me, I've rewritten it this way.
Aha!!! Now I'm starting to understand... In the loop, the variable a changes from 1 to 6. With values of this variable 1, 5 and 6 there is no action. Then just
Or in your style.
The result will be the same but it will run faster !
Now you need to get rid of the Statistic function, write its body three times in a row, replace the formal parameters in each of the three parts with actual parameters and remove duplicated variable declarations. The total code will be a bit longer but the execution will be faster. It makes sense to throw out print() - who exactly at this time will look through the message log? - Or replace it with Alert() to display it on the screen. Also, there is a variable namZz2 - does its value change?
I need to use stats() instead of stats(). Stupidly, I know I can rewrite three times, as you said, but the problem is that most likely the result of gathering statistics will have to add more arrays and I will sooner or later return to the original ones. That's why I offer you simple ways, which I already know, and they will unfortunately lead me to the beginning. That is why I look ahead, so that I do not have to return to it in the future!
how to put this code into the statistician!? to be a single procedure you at the beginning as I stated the question please look at!
Here's how it's calculated on the last bar:
Here is an extract from the working code ! How to collect it in one void Statistic without intermediate void Stat ! I would have to rework the whole code in order to gather all arrays into one and try to scratch it out from there !
The excerpt you cited from your working code is either wrong or your Statistic() function does nothing but print when called from Stat().
Anyway, it will stop right after return;.
Please give us the whole code to understand what you want.
For the record. Too many threads on the forum to help newbies on MQL4.
This thread is no longer supported and is closed.
Please direct all questions to any of the following active threads:
https://www.mql5.com/ru/forum/160683
https://www.mql5.com/ru/forum/160587
All further posts in this thread will be deleted.