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

 
Vitaly Muzichenko:

I can't touch it withOnCalculate(...) event, I can touch any function, but I can't touch this one. The timer is not an option, the indicator is needed not so often, and it would be better to use it with a click on a graphic item.

How to implement it?

You catch the click on the object in the indicator and the event handler, and then you recalculate the indicator buffers as at a new start. You do not need to pull OnCalculate
 
-Aleks-:

Can you please tell me how to correctly look for the most resource-intensive places in the code that load the CPU?

Run code profiling from the editor.
 
Artyom Trishkin:
Run code profiling from the editor.

Thanks, but how do you do it offline - on a day off?

 
What could be the problem?

A piece of code:

for(i=1; i<=Bars; i++)
{
if(Open[i]-Close[i]==0)

When testing, the debugger generates an error on the if line. Array out of range.

Thank you in advance.
 
Andy-D:
What could be the problem?

A piece of code:

for(i=1; i<=Bars; i++)
{
if(Open[i]-Close[i]==0)

When testing, the debugger generates an error on the if line. Array out of range.

Thank you in advance.
for(i=1; i<Bars; i++)
  {
   if(Open[i]-Close[i]==0)
     {

     }
  }
...
 
Sergey Gritsay:
for(i=1; i<Bars; i++)
  {
   if(Open[i]-Close[i]==0)
     {

     }
  }
...
Thanks helped, I guess I shouldn't have put "<="? It's weird, though. I don't understand why. Where do I put the plus sign?
 
Andy-D:
Thank you it helped, I guess I shouldn't have put "<="? It's weird, though. I don't understand why. Where to put the plus sign?
Array indexing starts with 0 and ends with Bars-1 (in this case). Therefore, the value of Bars results in an array overrun.
 
Andy-D:
Thanks helped, I guess I shouldn't have put"<="? Strange though. I don't understand why. Where to put a plus sign?
Because array indexing starts with zero, so, for example, if the number of bars in Bars is 1, then to get a value from this single bar, you must take the value of their cell with the index 0.

Here is a comparison table:

Number of bars in Bars
1 2 3 4 5 6 7 8 9 10 Outside array
Loop index referencing the data
0 (i<Bars)1 (i<Bars)2 (i<Bars)3 (i<Bars) 4 (i<Bars)5 (i<Bars) 6 (i<Bars) 7 (i<Bars)8 (i<Bars)9 (i<Bars) 10 (i==Bars)
 
Sergey Gritsay:
To do this, you need to create a server outside the local computer and transfer data through this server, respectively, for MT you write an indicator or advisor that processes this data, or put the terminals on a VPN server and there you set up a copier of deals from your account to your friends' accounts. Another option is to copy your trades executed on given levels through signals service. In general, you have to take into account your financial capabilities to order the appropriate software.
I have found an indicator (mq4) with similar mapping principle. I have seen its results and they do not suit me. I've got my own data. I think it's more accurate. I have my own data. Can I edit it to make it more accurate and remove some unnecessary mappings and specify the path to my data? Just take it as a basis.
 
Artyom Trishkin:
Since array indexing starts with zero, for example, if the number of bars in Bars is 1, then to get the value from this single bar, we need to take the value of their cell with index 0.

Here is the comparison table:

Number of bars in Bars
1 2 3 4 5 6 7 8 9 10 Outside array
Loop index referencing the data
0 (i<Bars)1 (i<Bars)2 (i<Bars)3 (i<Bars) 4 (i<Bars)5 (i<Bars) 6 (i<Bars) 7 (i<Bars)8 (i<Bars)9 (i<Bars) 10 (i==Bars)
Thank you very much, that makes more sense now.
Reason: