[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 126

 
eddy:
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

 
sergeev:
so nothing will happen. The function Funk2 - does not return any value. it is void

In this case, the function in question is

void TestFunction (double &return_value1, double &return_value2)
 
sergeev:
Funk2 function
funk:)
 
eddy:

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? ))))

 
Sergey_Rogozin:

So it closes off the possibility of turning on at all.

So don't set the DecreaseFactor or set it small)
 
Sergey_Rogozin:

losses - unprofitable trades

DecreaseFactor - the extent to which the Lot is reduced on a series of losing trades.

extern string a = "ЛОТ ММ";
extern bool   MM=false;      // если false - то работает обычный лот, если true - работает ММ
extern double Lots = 0.1;    // обычный лот
extern double 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);}
 
Martingeil:

Yes, that's exactly what I'm talking about.

What happens when losses / DecreaseFactor >= 1 ????

Ahhhh! It opens with the initial Lot.

Thanks.

 
Sergey_Rogozin:

Yes, that's exactly what I'm talking about.

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
lot = minlot;
 
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.

Yes, thank you!

Got it.