DecreaseFactor - the extent to which the Lot is reduced on a series of losing trades.
externstring a = "ЛОТ ММ";
externbool MM=false; // если false - то работает обычный лот, если true - работает ММexterndouble Lots = 0.1; // обычный лотexterndouble balans = 200; // баланс при увеличении которого, следующий лот будет увеличен на лот MaximumRisk При ММdouble MaximumRisk = 0.1; // лот прибавляемый к предыдущему при ММdouble DecreaseFactor = 3.0; // если позиция проигрышная то следующая позиция откроется с лотом /3 При ММdouble LotsOptimized() {
double lot = Lots;
double minlot = MarketInfo(Symbol(), MODE_MINLOT);
double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
if (MM){
int orders = OrdersHistoryTotal();
int losses = 0;
lot = NormalizeDouble(AccountFreeMargin() * MaximumRisk / balans, 2);
if (DecreaseFactor > 0.0) {
for (int i = orders - 1; i >= 0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == FALSE) {
Print("Error in history!");
break;
}
if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;
if (OrderProfit() > 0.0) break;
if (OrderProfit() < 0.0) losses++;
}
if (losses > 1) lot = NormalizeDouble(lot - lot * losses / DecreaseFactor, 2);
}}
if(lot < minlot) lot = minlot;
if(lot > maxlot) lot = maxlot;
return (lot);}
What happens when losses / DecreaseFactor >= 1 ????
will be divided by 3 if the previous one was unprofitable, if the lot is less than the minimum at division then the minimum lot function will take effect
Martingeil: If the previous one was unprofitable the lot will be divided by 3. If the lot is less than the minimum lot, the minimum lot function will take over.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Well, what are losses and the DecreaseFactor ?
losses - unprofitable trades
DecreaseFactor - the degree of Lot reduction on a series of losing trades.
Sergey_Rogozin:
If DecreaseFactor=3 and losses=3, then according to the formula we get Lot=0 !!!
In case losses>3, we get Lot<0
that's why the deal will not be opened, that's the calculation)
if there are too many losing trades
so nothing will happen. The function Funk2 - does not return any value. it is void
In this case, the function in question is
Funk2 function
that's why the deal won't open, that's what we're counting on)
if there's already a lot of losses.
So that closes off the possibility of getting involved at all.
Where will the profitable trades come from then? ))))
So it closes off the possibility of turning on at all.
losses - unprofitable trades
DecreaseFactor - the extent to which the Lot is reduced on a series of losing trades.
Yes, that's exactly what I'm talking about.
What happens when losses / DecreaseFactor >= 1 ????
Ahhhh! It opens with the initial Lot.
Thanks.
Yes, that's exactly what I'm talking about.
What happens when losses / DecreaseFactor >= 1 ????
If the previous one was unprofitable the lot will be divided by 3. If the lot is less than the minimum lot, the minimum lot function will take over.
Yes, thank you!
Got it.