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

 
tuner:
You could, for example, switch the timeframe programmatically and then switch it back if necessary.
I don't think this is how variables are reset.
 
tuner:
Or try saving the template and then loading it back in
Great idea! Is that possible?
 

I don't know what...

I wrote three versions of the EA, all compiled without errors, but in the tester something strange happens - on M5 it opens one position and does not close it, but on M1 it opens on every tick and closes on the next one, regardless of the prescribed conditions.

 
abeiks:
I don't think that's how variables are reset.
External variables are reset because OnInit() is called when the timeframe is changed
 
abeiks:
Great idea! Is that possible?
Probably... there are built-in functions in MQl4 related to saving and loading templates: ChartSaveTemplate, ChartApplyTemplate
 
rapid_minus:

I don't know what...

I wrote three versions of the EA, all compiled without errors, but in the tester something strange happens - on M5 it opens one position and does not close it, but on M1 it opens on every tick and closes on the next one, regardless of the prescribed conditions.

Tell me please, if you write a multiplying function

double f(double a1, double a2)
{
 return(a1*a2+1);
}

Will this function ever result in 2*2=4 or not?

I mean that no compiler checks the code's logic. And your Expert Advisors are full of logical errors.

 
AlexeyVik:

Tell me please, if you write a multiplication function

Will this function ever result in 2*2=4 or not?

I mean, no compiler checks the logic of code. And your Expert Advisors are full of logical errors.

I got it. only one thing I don't understand.

ZZY: and which error may behave differently in different TFs?

ZZZY: for example, where is the logical error here:

void CritClose() 
{ 
  for (int ord = OrdersTotal()-1 ; ord >= 0; ord--) 
  { 
    if(!OrderSelect(ord,SELECT_BY_POS,MODE_TRADES))Comment("Не найдено открытых ордеров. Ошибка #",GetLastError());
     
    if (OrderSymbol() == Symbol()) 
    {if ((OrderMagicNumber()==10011 || OrderMagicNumber()==10033 || OrderMagicNumber()==10133)&&(((условие А) && (условие Б)&&(условие В)) || ((условие Г) && (условие Д)&&(условие Е))))      
          {        
          ord_close=OrderClose(OrderTicket(),0.1, Bid, 0, Red);          
            if (ord_close = false)          
               { Comment("Закрытие позиции БАЙ завершилось с ошибкой #",GetLastError()); }            
               else  { Ord=0; }
          }
      else if (... и т.д....
 

Ow! Guru! Did you break your finger in the palm?

 
rapid_minus:

I get it. the only thing I don't understand is which ones?

ZS: and which error might behave differently in different TFs?

ZZY: for example, where is the logical error here:

The logical error here is that the program structure is wrong. After the comment "Not found ... " the code will continue executing as if it had been found. Vladimir, read a textbook, will you?
 
rapid_minus:

Ow! Guru! Did you break your finger in the palm?

Did you think I had nothing else to do? I'm surprised to hear that...

No one can find a logical error but you, because no one knows what you're up to. And everyone has a different writing style and for me personally it's hard to read your code, I can't see pairing of parentheses. Each closing parenthesis is located below opening one and each pair of parentheses is not equidistant from left edge. This was worked out when the brackets weren't highlighted, and they aren't highlighted in the forum now either.

What is (condition A, B, C, D, D, E)? Apparently there is an error here, but not for sure. And you are sure that the orders are opened with the listed magicians? Do you understand the methods of finding logical errors? You have been repeatedly advised to unprint the code and see where the execution comes in and where it does not, and you keep asking for help.