Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 648

 
intrade:
The problem seems to be that when you change timeframe, the Expert Advisor is pre-initialised, which leads to a lot of empty variables. And if they are empty, it means that there are supposedly no trades and we have to open new ones.

So do not create empty variables. And check what has already been opened by the symbol, by magician, and if necessary - by timeframe. But there are no telepaths here, there is nothing to say without the code.
 
intrade:
The problem seems to be that when you change the timeframe, the Expert Advisor is pre-initialised, which leads to a lot of empty variables. And if they are empty, it means that there are supposedly no trades and we have to open new ones.

The question is why the fuck do we need to change the timeframe when the Expert Advisor is running? You must set a taboo - put the EA, forget about the chart, if you need to see something, open a new chart and do with it what you want.
 
intrade:
The trouble is that when you change the timeframe, the Expert Advisor pre-initializes, which leads to a lot of empty variables. And if they are empty, it means that supposedly there are no trades and we have to open new ones.


Use timers like, for example:

iClose

Returns the close price of the bar (specified by the shift parameter) of the corresponding chart.

doubleiClose(
stringsymbol,// symbol
inttimeframe,// period
intshift// shift
);

And change the timeframe as much as you want! Look in the Doc, it's all there for you!

 
Do Prints slow down EA optimisation or are they not processed?
 
ClanVi:
Do Prints slow down EA optimization or are they not processed?

Yes they do, any line of code takes CPU time, and code that makes messages or works with graphical objects slows down program execution considerably...
 
ClanVi:
Do Prints slow down EA optimization or are they not handled?


This is very easy to avoid! When the code has been tested in the tester, put it in front of Print or Comment

  if(!IsOptimization() || !IsTesting()) 

And it won't stitch!

 
VOLDEMAR:

Yes they do, any line of code takes CPU time and code that makes messages or works with graphical objects slows down program execution considerably...
Graphical objects are ignored in optimizer and tester if not in visual mode, but prints are interesting to me...
 
Good afternoon everyone. Gentlemen advise what to do with the error "Error 6" no connection with the server, but the ticks go and everything is as it should.... Owls on the test... today I got up and here you are..... there are 4 owls 5M 15M 30M 1H such error has thrown out in logs on M5 M15 M30 all at different times and prices.... Who has experience with this kind of thing please help. Thanks.
 

The Debugger doesn't work - what's wrong?

Best wishes to all forum members!

No one has answered my question posed back on page 644. I must have asked it wrong, so I'll ask it again. So,

Metatrader Bild 646, Editor Bild 934. Here is a simple indicator:

class CDebuggerFix { } ExtDebuggerFix; //Это заклинание, исправляющее известный баг.
void start()                     
  {
   int i=10,                           
       k3;
   string k2;
  
     while(i>=1)                      
     {
      k2=Symbol();
    
      if (k2=="EURUSD") k3=3;
      if (k2=="USDCHF") k3=4;
      if ((k2=="EURUSD"||k2=="USDCHF")!=True) k3=5;
       Alert("k2=",k2,"\n","k3=",k3);
       
          i--;                         
      }
  return;
  }

I run it on the EURUSD, M1 chart, and this is what I get:


I.e. everything is as it should be.

And now I make a breakpoint before Alert and run the Debugger:


USDCHF,H1 chart appears. Where is it coming from? OnlyEURUSD, M1 was open.

I press OK and this is what I see:


I.e. the indicator takes data exactly from this USDCHF,H1. What is the problem here?

The second question. The Editor does not place the written script in the folder Scripts but in the folder MQL4 and places the compiled file there as well. I have to manually drag and drop the source code to Scripts folder, then compile it and the script will appear in Navigator only then. Indicators don't have that problem, they go straight to their folder. Am I doing something wrong or is the Editor making a mistake?

Good luck to whoever answers me.

 
realgentleman:

The Debugger doesn't work - what's wrong?

In the Service - Settings meta-editor, Debug tab, what is set?

Reason: