not enough money

To add comments, please log in or register
zifu wang
338
zifu wang  

Dear All,

ACCOUNT BALANCE:10000. 00 USD

Tried to place an oder through EA. 

CTrade::OrderSend: instant buy 10.00 EURUSD at 1.27443 tp: 1.28443 [not enough money] 

Got an error:not enough money

why? please advise. 

Biantoro Kunarto
19841
Biantoro Kunarto  

if you buy 10 lot EURUSD at 1.27443 with leverage 1:100 then your account isn't enough:

margin required = 10 x 100.000 x 1.27443 /100 = 12744.3 > 10000

Enrico Lambino
6611
Enrico Lambino  
CTrade does not check the margin before sending the order. You will need an instance of CAccountInfo to get the amount of margin required and then compare it with the amount of useable margin.
candra_a
36
candra_a  
bicause CTrade does not minimum TP in your order. check up your TP.
Ali Sabbaghi
66
Ali Sabbaghi  
zifu wang:

Dear All,

ACCOUNT BALANCE:10000. 00 USD

Tried to place an oder through EA. 

CTrade::OrderSend: instant buy 10.00 EURUSD at 1.27443 tp: 1.28443 [not enough money] 

Got an error:not enough money

why? please advise. 

hi.

Chech your trade volum.

use this code:


double CheckLots (int risk_percent,double Stoplost_point, double Static_Lot) {

    double Margin_Required=MarketInfo(Symbol(), MODE_MARGINREQUIRED);

    double lotmin=MarketInfo(Symbol(), MODE_MINLOT);

    double lotmax=MarketInfo(Symbol(), MODE_MAXLOT);

   if (risk_percent<=0) return (Static_Lot);

   double lots=0;

   lots=NormalizeDouble( (AccountBalance()*Risk_Percentage/100) / (Tick_Value*sl_size), 2 );

   if (lots*Margin_Required>AccountFreeMargin()) {

      error("Not enough money to take " + DoubleToStr(lots,2) +" lots.");

      lots=AccountFreeMargin()/Margin_Required;

      }

   lots=MathFloor(lots/Lot_Step + 0.5)* Lot_Step;   

   if ( lots < lotmin ) lots=lotmin;

   if ( lots > lotmax ) lots=lotmax;

   if ( lots > MaxLot) lots = MaxLot;

   return(lots);

}

To add comments, please log in or register