Simple question regarding using default values in function calls.

 

As the topic suggests, I want to find out how to "skip" a parameter while calling a function.

Being specific, I want to skip the price parameter (thus making the Buy function use default price such as SYMBOL_ASK)

m_Trade.Buy(lots,symbol,price,stoploss,takeprofit,comment);

So there it is, I want to skip the parameter in red, such as follows:

M_Trade.Buy(1,my_symbol,0,50,300,NULL);

If I use 0, the EA doesn't fire up as prices never turns to zero. What value can I use to determine I want to use current price on my Buy function?


Thanks a ton!

 

Why don't you just add an if statement inside the function which checks the value of the price parameter and changes it if it's zero:

if (price==0) price=Ask;
 
Filter:

Why don't you just add an if statement inside the function which checks the value of the price parameter and changes it if it's zero:

Brilliant.. this might work. I'll give it a shot!

 

Thank you. 

 
Welcome mate :)