i must be really tripping, that script gives me correct result, but in my EA im getting that totally incorrect calculation, and i lifted the script and pasted into the EA :nuts:

auto lot size based on risk% 8 replies
Which would you prefer: increasing lot size or TP size? 21 replies
At what lot size/account size do you have scale issues? 35 replies
calculating lot size based on money to risk, not % 4 replies
04:12:46 Assistant USDCZK,M15: Alt calculation; Capital=48939 Risk=1.0% Stoploss=27 Lots=30.66 04:12:46 Assistant USDCZK,M15: Lot size calculated using 1.00000000% and stop: 27.00000000 = 30.65963366 04:12:46 Assistant USDCZK,M15: Using lot size of 30.65963366 04:12:46 Assistant USDCZK,M15: Checking param: M5 price: 1.07280000 sl: 1.07550000 04:12:46 Assistant USDCZK,M15: Here we go... 04:12:47 Assistant USDCZK,M15: Here we go... 04:13:09 Assistant USDCZK,M15: OrderSend failed with error #134 04:15:07 PosizionSize AUDUSD,M15: loaded successfully 04:15:07 PosizionSize AUDUSD,M15 inputs: risk=1; stoploss=36; 04:15:07 PosizionSize AUDUSD,M15: Alert: Capital=48939\nRisk=1.0% Stoploss=36 Lots=1.36 04:15:07 PosizionSize AUDUSD,M15: Capital=48939 Risk=1.0% Stoploss=36 Lots=1.36
double CalcLotSize(int iSL) { int iPipMult[]={1,10,1,10,1,10,100}; double dRiskCapital=MaxRisk/100*AccountBalance(); double tmpLot = dRiskCapital/(iSL*MarketInfo(Symbol(),MODE_TICKVALUE)*iPipMult[Digits]); Print("Alt calculation; Capital=",DoubleToStr(AccountBalance(),0),"\nRisk=",DoubleToStr(MaxRisk,1)+"%", "\nStoploss=",DoubleToStr(iSL,0),"\nLots=",DoubleToStr(tmpLot,2)); return(tmpLot); }
Dislikednah raptor the EA is running on that chart but not executing on that pair - its still AU.
And the margin issue is after the calculation is incorrect.
xaphod i almost wish u could remote login to my PC so u can see im not on drugs ..Ignored
DislikedNot if you are using a chart-specific function like "Symbol()" and a chart-specific property like "Digits" in your lot calculation.Ignored
Disliked{quote} hahahah u legend !! see thats wot a 2nd pair of eyes does ! Indeed, thats exactly it, thx very much all for helping !Ignored
DislikedI usually use this function: double CalcLots(double Risk) { double tmpLot = 0, MinLot = 0, MaxLot = 0; MinLot = MarketInfo(Symbol(),MODE_MINLOT); MaxLot = MarketInfo(Symbol(),MODE_MAXLOT); tmpLot = NormalizeDouble(AccountBalance()*Risk/1000,2); if(tmpLot < MinLot) { Print("LotSize is Smaller than the broker allow minimum Lot!"); return(MinLot); } if(tmpLot > MaxLot) { Print ("LotSize is Greater than the broker allow minimum Lot!"); return(MaxLot); } return(tmpLot); }Ignored