Patryk Kalisz:
Hi all,
I couldn't find the answer anywhere, so I'm starting a new thread. I have defined so called LockedInBalance that represents the account's balance + profits that are 'locked in' by the Stop Loss. That allows me to tell what is my real minimum account balance given current environment.
Now, I want to do two things:
1. Add the LockedInBalance value at each time step of the Strategy Tester Graph (print screen)
2. Calculate statistics (Sharpe, Sortino, Drawdown etc.) on that measure, not on equity/balance.
Any help is very much appreciated.
Hi all,
I couldn't find the answer anywhere, so I'm starting a new thread. I have defined so called LockedInBalance that represents the account's balance + profits that are 'locked in' by the Stop Loss. That allows me to tell what is my real minimum account balance given current environment.
Now, I want to do two things:
1. Add the LockedInBalance value at each time step of the Strategy Tester Graph (print screen)
2. Calculate statistics (Sharpe, Sortino, Drawdown etc.) on that measure, not on equity/balance.
Any help is very much appreciated.
To accomplish that you need to contact your EA author (please confirm you have open-code mql5 file in your possession).
NOTE: Traders and coders are working for free:
- if it is interesting for them personally, or
- if it is interesting for many members on this forum.
Freelance section of the forum should be used in most of the cases.
Trading applications for MetaTrader 5 to order
- 2024.12.11
- www.mql5.com
The largest freelance service with MQL5 application developers
Oleksandr Medviediev #:
To accomplish that you need to contact your EA author (please confirm you have open-code mql5 file in your possession).
NOTE: Traders and coders are working for free:
- if it is interesting for them personally, or
- if it is interesting for many members on this forum.
Freelance section of the forum should be used in most of the cases.
I am my EA author and I do have the code in my possession, obviously. I just can't figure out how to do this. I see I forgot to attach the snippet for the LockedInBalance definition.
double LockedInBalance() { double AccountBalance = AccountInfoDouble(ACCOUNT_BALANCE); double lockedInBalance = AccountBalance; double positionPoints = SymbolInfoDouble(_Symbol, SYMBOL_POINT); // Iterate through all open positions for (int i = 0; i < PositionsTotal(); i++) { if (PositionSelectByTicket(PositionGetTicket(i))) { // Get position's opening price and stop loss double openPrice = PositionGetDouble(POSITION_PRICE_OPEN); double stopLoss = PositionGetDouble(POSITION_SL); double positionLot = PositionGetDouble(POSITION_VOLUME); // Calculate locked-in profit/loss double profitLoss = 0.0; if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { OrderCalcProfit(ORDER_TYPE_BUY,_Symbol,PositionGetDouble(POSITION_VOLUME),openPrice,stopLoss,profitLoss ); } else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { OrderCalcProfit(ORDER_TYPE_SELL,_Symbol,PositionGetDouble(POSITION_VOLUME),openPrice,stopLoss,profitLoss ); } // Add profit/loss to locked-in balance lockedInBalance += profitLoss; } } return lockedInBalance; } double DepositedCapitalNet() { HistorySelect(0,TimeCurrent()); int deals=HistoryDealsTotal(); ulong deal_ticket; int deal_type; double deal_volume; double total_volume=0; for(int i=0;i<deals;i++) { deal_ticket=HistoryDealGetTicket(i); deal_type =HistoryDealGetInteger(deal_ticket,DEAL_TYPE); if (deal_type==2) { deal_volume = HistoryDealGetDouble(deal_ticket,DEAL_PROFIT); total_volume+=deal_volume; } } return(total_volume); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I couldn't find the answer anywhere, so I'm starting a new thread. I have defined so called LockedInBalance that represents the account's balance + profits that are 'locked in' by the Stop Loss. That allows me to tell what is my real minimum account balance given current environment.
Now, I want to do two things:
1. Add the LockedInBalance value at each time step of the Strategy Tester Graph (print screen)
2. Calculate statistics (Sharpe, Sortino, Drawdown etc.) on that measure, not on equity/balance.
Any help is very much appreciated.
The code for the LockedInBalance() in my EA is as below: