[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 368

 

Good afternoon.

I have to determine the opening of a new bar. I have inserted in my Expert Advisor a pure example function from the MQL tutorial

void Fun_New_Bar() // New bar detection function
{
static datetime New_Time=0; // Current bar time
bool New_Bar=false; // No new bar
if(New_Time!=Time[0]) // Compare the time
{
New_Time=Time[0]; // Time is now
New_Bar=true; // Caught the new bar
}
return(New_Bar);
}

It gives a single error '(' - function definition unexpected - I understand this as an unexpected function definition.

I defined the "New_Time" variable before the int function as datetime New_Time;- without it the compilation gave an error of undefined variable.

The function is called in the main program as follows:

Fun_New_Bar(); // Calling f-i
if (New_Bar==false) // If the bar is not new...
return;

Who can tell me why it all does not work?

And another interesting observation - when you fix something, you copy it - no errors, then you copy it again - again

'(' - function definition unexpected - that's why. Am I writing so obfuscated that the compiler cannot understand me right away?

 
keekkenen >> :
happens, sometimes you print crooked places and see 0.0000 = 0 and it doesn't work - false, normalise the values just in case.

I added a new condition that duplicates the problematic one and the problem is solved.

Thank you!


PS It's good that in my case the error with orders reported the problem - in others the EA's logic may be completely broken,

without any message, and there will be no way to know about it :(((

 

The function is declared as void, i.e. it returns nothing, but in the code it says return(New_Bar); this is the reason for the error...

it must be declared according to the returned variable type - bool Fun_New_Bar()

and use it accordingly if ( !Fun_New_Bar() ) return(0);

 
keekkenen писал(а) >>

The function is declared as void, i.e. it returns nothing, but in the code it says return(New_Bar); this is the reason for the error...

it must be declared according to the returned variable type - bool Fun_New_Bar()

and use it accordingly if ( !Fun_New_Bar() ) return(0);

I had it exactly as "bool Fun_New_Bar()" in the first version, but the error was the same, so I named the function as in the manual - void. I've implemented your tip and there's no change - the error is the same.

But one change has occurred - the error is found on line 279 (this is the comment line), while the function starts at 280

A related question is whether it is acceptable to load the int() function with some one-time analysis block, for example, determining the values of the two latest reversals on the indicator.

I have done so. May it cause a hang-up of the Expert Advisor?

 

function definition unexpected - most likely missing or extra parenthesis in code BEFORE Fun_New_Bar function,

Look through the code carefully and you'll probably find the problem.

 
keekkenen писал(а) >>

function definition unexpected - most likely missing or extra parenthesis in code BEFORE Fun_New_Bar function,

Look through the code carefully and you'll see what's wrong.

I will look for it now. I will try to squeeze this function into the place where I am calling it from. Two functions with such an error have already been copied without errors after being moved to the place of call. What's more, if the "faulty" function is moved to the place of call, the same error skips to the other function, not necessarily next in order.

 
alsu >> :

1. Install QIPInfium if you haven't already done so

2. Create a separate ICQ account for the terminal

3. Install and configure the MsgBox plugin - detailed instructions

From the Expert Advisor (indicator, script), which should produce signals, write files with the necessary messages in the OutBox folder, as explained in the instructions on the link above. To write to the file outside the terminal directory, you can, for example, use the ZI_File_Functions_Full_Lib library


That's how, with a little bit of google and some creativity, you can do anything you want in four steps with minimal programming:))))

Thanks, it works :)

 

When running the EA in demo mode, the order confirmation window keeps popping up, like in manual trading. This function has been cancelled in the options, but is still caught somewhere.

Is there any way to cancel the confirmation window?

 
Andrei01 >> :

When running EA in demo mode, order confirmation window keeps popping up, like in manual trading. The options have cancelled this function, but it is still caught somewhere.

Is there any way to cancel this confirmation window?


settings_Mt service-settings-advisors


expert_settings

 

thanks. that's exactly what doesn't work as it's written somewhere in the profile and it couldn't be undone. the problem was solved by re-creating the profile.