Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1475

 
Alexey Viktorov #:

Look for ...

Thank you. But that's not what I'm looking for at all.

Apparently I again failed to formulate the question correctly :(

I'm interested in how to extract position information from a ReportTester.xlsx or .tst file .

What you suggested is not in the report.

 
MrBrooklin #:

   //лот = процент риска от баланса / (размер стоплосса * Размер минимального изменения цены в валюте депозита / Минимальный шаг изменения цены в пунктах)
   eLot=AccountInfoDouble(ACCOUNT_BALANCE)*eRisk/100/(MathAbs(ePrice-eStopLoss)*SymbolInfoDouble(eSymbol,SYMBOL_TRADE_TICK_VALUE)/SymbolInfoDouble(eSymbol,SYMBOL_TRADE_TICK_SIZE));
 
Aleksei Stepanenko #:

Thank you, Alexey, for the code! Tomorrow I will go into your formula in more detail.

Regards, Vladimir.

 
You're welcome)
Here price and loss are prices. If your loss is in pips, use point.
 
Aleksei Stepanenko #:
You're welcome)
Here price and loss are prices. If your loss is in pips, use point.

Alexey, if I convert stop loss to points, I get nonsense. The thing is that in the script I used a formula found on the Internet. I don't remember where, it was just a long time ago. I made a table in Excel using this formula and used it when necessary. Here is how it looks like:

That's why I turned to the community to clarify how true it is. The formula itself in the Exel table looks like this:

лот = (баланс * риск (в %) * 0,01) / (стоп-лосс (в пунктах) * курс валюты (в моем случае в руб.))

Regards, Vladimir.

 

Vladimir, everything works

input int eLoss=2000;
input double eRisk=5.0;

double eLot=AccountInfoDouble(ACCOUNT_BALANCE)*eRisk/100/(eLoss*SymbolInfoDouble(eSymbol,SYMBOL_POINT)*SymbolInfoDouble(eSymbol,SYMBOL_TRADE_TICK_VALUE)/SymbolInfoDouble(eSymbol,SYMBOL_TRADE_TICK_SIZE));
 
Aleksei Stepanenko #:

Vladimir, everything works

Alexey, sorry, but we did not understand each other. The misunderstanding was more on my part. I thought that you were recommending to apply a point in my function. ))

Regards, Vladimir.

 
Ah, got it)
 
Aleksei Stepanenko #:

Vladimir, everything works

Lots of divisions without checking the divider to zero. Explosive.

 
Artyom Trishkin #:

Many divisions without checking the divider for zero. Explosive.

Thanks, Artyom, for the tip! I will definitely add the check.

Regards, Vladimir.

Reason: