Cumulative position price - page 2

 
Malacarne:

Why don't you simply use trade.Sell( ... ) with it's own parameters ?

You don't need to create a void function for that... 

well. i'm a newbie i just discovered mql5. plus, i may call this function many times, in many circumstances so ... for the param, no idea ?
 
blouf:
well. i'm a newbie i just discovered mql5. plus, i may call this function many times, in many circumstances so ... for the param, no idea ?
Please take a look at this link.
 
blouf:

I want to call it from another function and be allowed to pass how much lot i want : Sell(0.01);

EDIT : if no param use a default value

void Sell(double Lots=0.01)
{
   double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);
        Trade.PositionOpen(_Symbol, ORDER_TYPE_SELL, Lots, Bid, 0, 0, OrderComment);

}
 
angevoyageur:
Then if i use Sell(0.02) it will bypass lots' default value right ?
 
blouf:
Then if i use Sell(0.02) it will bypass lots' default value right ?
Right, Sell(0.02) will set Lots=0.02, and Sell() will set Lots=0.01
Reason: