How to optimise an advisor correctly - page 5

 
Loring писал (а) >>
I don't claim to be omnipotent... >> It's still raw, but it seems to be entitled to life... I need like-minded people (programmers) who can help with the idea... Somewhere and I will help them. I have experience...

Can you be more specific? If you're shy (just kidding), the coordinates are in the profile.

 

Vinin, check your email... I'm reading your VininE Game right now. Very elegant. Russia is rich with smart people...

 
Found an unfortunate error in calculating lot size. I apologise in advance... No offence intended... Pedagogical background...
       double lot = NormalizeDouble(AccountFreeMargin() * MaximumRisk/100000/step,1); //*step
Great reinvestment algorithm. I don't get it. I'll look through the manuals while the Expert Advisor is running in the tester...
 
Loring писал (а) >>
Found an unfortunate error when calculating lot size. >> I apologise in advance... No offence meant... Pedagogical background. Great reinvestment algorithm. I don't get it. I'll look through the manuals while my Expert Advisor is running in the tester...

Maybe I forgot to multiply by step. And rounding 0.

 

On the contrary, I made an extra multiplication... The lot immediately decreased by an order of magnitude and the algorithm always smoothed it out to 0.1... I have a feeling that it may not work in Japanese. Divide by a fixed coefficient, and it should, as it seems, be dominated by Point... I will check it later.

But the way he swallowed lots... Profit is growing by leaps and bounds. Only risk is not absolutely clear. ( I understand 1/MaximumRisk). I'll convert it to percentages for myself... It's good when I have the source code, otherwise I wondered why the risk is set as an integer, and with a decimal point....

 
Loring писал (а) >>

On the contrary, I made an extra multiplication... The lot immediately decreased by an order of magnitude and the algorithm always smoothed it out to 0.1... I have a feeling that it may not work in Japanese. Divide by a fixed coefficient, and it should, as it seems, be dominated by Point... I will check it later.

But the way he swallowed lots... Profit is growing by leaps and bounds. Only risk is not absolutely clear. ( I understand 1/MaximumRisk). I'll convert it to percentages for myself... It's good when I have the source code, I had long to understand why the risk is given as an integer, and with a decimal point....

Here is my function.

double getLots() {
   if (MaximumRisk>0) {
      double minlot=MarketInfo(Symbol(),MODE_MINLOT);
      double maxlot = MarketInfo(Symbol(), MODE_MAXLOT);       
      double step=MarketInfo(Symbol(),MODE_LOTSTEP);

      double lot = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 100000.0/step, 0)*step; 
      lot=MathMax(MathMin(lot,maxlot),minlot);
      
   }
   else lot=Lots;
   return(lot); 
}
And the letter was read and answered. But there are more questions than answers.
 

Thanks for the answer...

And NormalizeDouble rounds to an integer and the lot step is 0.1 ... The result is lot =0 and

lot=MathMax(MathMin(lot,maxlot),minlot);
aligns it to minlot... Tested more than once by simple log prints... After rounding was corrected an extra multiplication by step came out... Also checked... If you replace it with my variant, then reinvestment algorithm is enabled and each subsequent lot grows with allowable risk... or I don't understand the program... I'll show you what I've got.
 
Loring писал (а) >>

Thanks for the answer...

And NormalizeDouble rounds to an integer and the lot step is 0.1 ... The result is lot =0 and

>> it evens it out to minlot... Checked more than once by simple log prints... After rounding was corrected, extra multiplication by step came out... Also checked... If you replace it with my variant, then reinvestment algorithm is enabled and each subsequent lot grows with allowable risk... or I don't understand the program... I'll show you what I've got.

Perhaps there is an extra 0 in the division.

And I would like to see the result.

 

So that's what came out ...

 
and consequently
Reason: