How to optimise an advisor correctly - page 6

 

The first one on x is SL and the one on y is TP.

I think the left is the positive zone and the right is a random hit... Well SL on euro quid can't be 190 or more for M5 period...

 
Loring писал (а) >>
and accordingly.

Watch out, don't get carried away with martingale. The EAs were bespoke, I just warned them that I would put them out there. I don't like this technology. It's very risky. You may use it when the probability of a good outcome is quite high. The only thing left to do is to create such a mechanism.

 

But a little testing is possible .... The result, by the way, is close to my algorithm. So I won't tear my hair out... But I want to get acquainted.

 
Yeah, well... As Zverev used to say, "The star is in shock"... The algorithm does behave strangely, or as it likes to be... That's when you turn on reinvestment.
Strategy Tester Report
VininE_Game_1
FxProfit-Demo (Build 217)
Символ    EURUSD (Euro vs US Dollar)
Период    5 Минут (M5) 2008.06.01 22:05 - 2008.06.27 21:55 (2008.06.01 - 2008.06.29)
Модель    Все тики (наиболее точный метод на основе всех наименьших доступных таймфреймов)
Параметры    Lots=0.1; MaximumRisk=6; cmd=0; TP=262; SL=18; MagicNumber=0; 

Баров в истории    6749    Смоделировано тиков    152889    Качество моделирования    90.00%
Ошибки рассогласования графиков    0                

Начальный депозит    1500.00                
Чистая прибыль    7908.10    Общая прибыль    11037.80    Общий убыток    -3129.70
Прибыльность    3.53    Матожидание выигрыша    790.81        
Абсолютная просадка    662.60    Максимальная просадка    4846.40 (54.75%)    Относительная просадка    54.75% (4846.40)

Всего сделок    10    Короткие позиции (% выигравших)    5 (20.00%)    Длинные позиции (% выигравших)    5 (40.00%)
    Прибыльные сделки (% от всех)    3 (30.00%)    Убыточные сделки (% от всех)    7 (70.00%)
Самая большая    прибыльная сделка    6359.60    убыточная сделка    -1280.00
Средняя    прибыльная сделка    3679.27    убыточная сделка    -447.10
Максимальное количество    непрерывных выигрышей (прибыль)    2 (4678.20)    непрерывных проигрышей (убыток)    4 (-612.60)
Максимальная    непрерывная прибыль (число выигрышей)    6359.60 (1)    непрерывный убыток (число проигрышей)    -1280.00 (1)
Средний    непрерывный выигрыш    2    непрерывный проигрыш    2

№    Время    Тип    Ордер    Объём    Цена    S / L    T / P    Прибыль    Баланс
1    2008.06.01 22:06    buy    1    0.90    1.5555    1.5535    1.5815    
2    2008.06.02 03:31    s/l    1    0.90    1.5535    1.5535    1.5815    -192.60    1307.40
3    2008.06.03 00:00    sell    2    0.80    1.5539    1.5559    1.5279    
4    2008.06.03 08:30    s/l    2    0.80    1.5559    1.5559    1.5279    -160.00    1147.40
5    2008.06.04 00:01    buy    3    0.70    1.5439    1.5419    1.5699    
6    2008.06.04 08:26    s/l    3    0.70    1.5419    1.5419    1.5699    -140.00    1007.40
7    2008.06.05 00:05    sell    4    0.60    1.5425    1.5445    1.5165    
8    2008.06.05 01:39    s/l    4    0.60    1.5445    1.5445    1.5165    -120.00    887.40
9    2008.06.06 00:00    buy    5    0.50    1.5584    1.5564    1.5844    
10    2008.06.09 09:39    t/p    5    0.50    1.5844    1.5564    1.5844    1293.00    2180.40
11    2008.06.10 00:00    sell    6    1.30    1.5640    1.5660    1.5380    
12    2008.06.12 14:34    t/p    6    1.30    1.5380    1.5660    1.5380    3385.20    5565.60
13    2008.06.13 00:00    buy    7    3.30    1.5454    1.5434    1.5714    
14    2008.06.13 02:20    s/l    7    3.30    1.5434    1.5434    1.5714    -660.00    4905.60
15    2008.06.15 22:10    sell    8    2.90    1.5417    1.5437    1.5157    
16    2008.06.16 10:47    s/l    8    2.90    1.5437    1.5437    1.5157    -577.10    4328.50
17    2008.06.17 00:02    buy    9    2.60    1.5470    1.5450    1.5730    
18    2008.06.26 13:44    t/p    9    2.60    1.5730    1.5450    1.5730    6359.60    10688.10
19    2008.06.27 00:00    sell    10    6.40    1.5751    1.5771    1.5491    
20    2008.06.27 10:39    s/l    10    6.40    1.5771    1.5771    1.5491    -1280.00    9408.10

And how well it all started...

 

But if the drawdown is > 50% ... I don't know who would risk investing. Looks like we should have used it as it is. Yet another example of the new being the enemy of the best...

 

After banging your head (stubbornly) against the table, the lot size calculation function takes the following form

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

       double lot = NormalizeDouble(AccountFreeMargin()/MarketInfo(Symbol(),MODE_MARGINREQUIRED)/MaximumRisk,1);
       lot=MathMax(MathMin(lot,maxlot),minlot);
      }
   else lot=Lots;
   return(lot); 
}

where MaximumRisk - part of capital (calculated as 1/MaximumRisk) that can be used when opening a position.

The necessity to divide and multiply by step is gone, because this function doesn't discard fractional parts, but rounds them off according to mathematics rules. Now the lot is calculated with the margin value, which decreases the risk. The "lot=MathMax(MathMin(lot,maxlot),minlot);" line will try to open a position of the minimum lot size (usually 0.1) anyway, which will increase the risk of the operation. You may want to disable it altogether. Again, it will only appear with insufficient deposition.

Once again I want to thank Viktor for the provided source code...

 
Loring писал (а) >>

After banging your head (stubbornly) against the table, the lot size calculation function takes the following form

Where MaximumRisk - part of equity (calculated as 1/MaximumRisk) that can be used to open a position.

There is no need to divide or multiply by step, because this function does not cut off fractional parts, but rounds them off according to mathematical rules.

Remember, not all brokerage companies have a lot increment of 0.1, there are other variants.

 
I'm feeling a little bit creepy... Seems right, but something's wrong. Then really /MaximumRisk/step,0)*step... I forgot that in some brokerage companies the step may be 0,001. It's nice to have someone to correct...
 

Then it must be like this... (not sure about the '0' in the rounding 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()/MarketInfo(Symbol(),MODE_MARGINREQUIRED)/MaximumRisk/step,0)*step;
       lot=MathMax(MathMin(lot,maxlot),minlot);
      }
   else lot=Lots;
   return(lot); 
}
 

I don't understand why the opening of the position was put in a separate function. One command can be executed locally... Or it's a scrap of something bigger... ТР and SL are transmitted not in that sequence in which they are in OrderSend... Thank goodness they are received as they are transmitted. Certainly not a big deal, but ....

Reason: