Dear all,
I have a bit of code below. To put it short, the first 3 line is to calculate lot size, if a stop order is sent with lot size information, there is no problem (Line 7), but if a market order is sent, the lot size is not valid (Line 5). The market order is ok, if I use a fix value instead (e.g. 0.4 in Line 5).
Please help if you know what I can do.
cheers,
kk007
01: double RiskCap = (0.6 + 0.2 * Grade) * AccountBalance() / 1000.0;
02: double TickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
03: double Lots = NormalizeDouble(RiskCap/(TgLevel-SlLevel)*10*Point/TickValue,1);
04: if (TgLevel==0.0){
05: ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SlLevel,0,"",255,0,Green);}
06: else {
07: ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,TgLevel,3,SlLevel,0,"",255,0,Green);}
I have a bit of code below. To put it short, the first 3 line is to calculate lot size, if a stop order is sent with lot size information, there is no problem (Line 7), but if a market order is sent, the lot size is not valid (Line 5). The market order is ok, if I use a fix value instead (e.g. 0.4 in Line 5).
Please help if you know what I can do.
cheers,
kk007
01: double RiskCap = (0.6 + 0.2 * Grade) * AccountBalance() / 1000.0;
02: double TickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
03: double Lots = NormalizeDouble(RiskCap/(TgLevel-SlLevel)*10*Point/TickValue,1);
04: if (TgLevel==0.0){
05: ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SlLevel,0,"",255,0,Green);}
06: else {
07: ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,TgLevel,3,SlLevel,0,"",255,0,Green);}