setting library function parameters to default. Is this ok?

blackmore
434
blackmore  

I have this function stored as library function. It is import in a header file:

double  hseGambit(double aPrice[], double bPrice[], int deal1=0, int deal2=0, int players=-1);

My question is about those 3 int parameters (highlighted in red) set to respective default values. If the EA call the fuction eg:

hseGambit(High,Low, 1, 5, 4);

Will this work well, and also during testing? And will this work well?

hseGambit(High, Low);

Thx.

William Roeder
25316
William Roeder  
Try it and find out. I seem to recall someone posted that default parameters do not work in DLLs.
blackmore
434
blackmore  
WHRoeder:
Try it and find out. I seem to recall someone posted that default parameters do not work in DLLs.

I was searching hi and low, cant find anything. I tried and it does seem not to work, for some unbeknowned reasons....

JC
1674
JC  

diostar:

[...] Will this work well, and also during testing? And will this work well?

The MQ4 documentation says that your second example ( hseGambit(High, Low); ) isn't going to compile. The page at https://docs.mql4.com/basis/variables/formal says "MQL4-library functions imported within other modules cannot have parameters initialized by default values"

In other words, you can have functions with optional parameters in a MQH file (which you #include) but not in a EX4 library or DLL (which you #import).

blackmore
434
blackmore  
jjc:

The MQ4 documentation says that your second example ( hseGambit(High, Low); ) isn't going to compile. The page at https://docs.mql4.com/basis/variables/formal says "MQL4-library functions imported within other modules cannot have parameters initialized by default values"

In other words, you can have functions with optional parameters in a MQH file (which you #include) but not in a EX4 library or DLL (which you #import).

Thx, that is the link I needed to search. Appreciate this.;-)