Position Sizing and Risk Management in MQL5

 

Hi All,
i have been working on MQL5 for quite a while, and found that people online talk about robust system "a framework" for the algorithm to work inside, the framework will take care for the risk management for the algorithm so the algorithm only focus on the entry, exist and the framework focus on the Trading System.
still the idea makes me confused, in this link [1] the guy creates an MQL5 code that use random entry and it succeeded with him, my opinion, it only succeeded because of his money management framework, as you can see, the functions as he use like the below list, my main point, what do you think those functions would be doing, and what kind of concepts that help making a better trading framework
all i think of is the framework calculate the lot size based on the risk percentage per trade

List of functions
bool GetNewChartCandle()
int GetNumberOfPositionsThisSymbol()
double GetCurrencyPairProfit()
void OpenStopLossBuyTrade(int StopLossPoints)
void OpenStopLossSellTrade(int StopLossPoints)
double SetEquityStop()
int SetMaxPositionsThisSymbol()
double SetPositionsSize()
void CheckForTick(string Signal, int TradingRisk)

[1] https:// www. youtube.com/watch?v=QDQ8iDvCE6A&t=204s

 
what kind of concepts that help making a better trading framework

A few things a framework might do:

1) Calculate lot size, SL/TP positions based upon ATR, profit percent, fixed, max/min, etc.

2) Handle complex logging

3) Create / manage a GUI

4) Handle MQL5 indicator definitions (i.e. initialize, Refresh, CopyData) for any # of indicators

5) Output trading metrics not natively handled by MT5

6) Error handling of all trading functions, checking margin, checking stops levels, checking freeze levels, etc.

7) Dump values specific to automated optimization.

8) alerts

9) . . . .

Basically, I think of a framework as anything that isn't the strategy, allowing you to easily try a new strategy without having to copy a lot of existing similar code from another EA.

Say I wanted to add Elder's SafeZone construct into my code base to automatically adjust SL levels. I would add that into the framework because it could, potentially, be used by any strategy. I'd use Input variables to turn it on/off and adjust levels.

Another way to look at it:

I have only one EA. All my code is OOP. When I want to test a new strategy, I simply extend my strategy class, plug it into my code base, compile, and I still have only one EA.

 
Anthony Garot:

A few things a framework might do:

1) Calculate lot size, SL/TP positions based upon ATR, profit percent, fixed, max/min, etc.

2) Handle complex logging

3) Create / manage a GUI

4) Handle MQL5 indicator definitions (i.e. initialize, Refresh, CopyData) for any # of indicators

5) Output trading metrics not natively handled by MT5

6) Error handling of all trading functions, checking margin, checking stops levels, checking freeze levels, etc.

7) Dump values specific to automated optimization.

8) alerts

9) . . . .

Basically, I think of a framework as anything that isn't the strategy, allowing you to easily try a new strategy without having to copy a lot of existing similar code from another EA.

Say I wanted to add Elder's SafeZone construct into my code base to automatically adjust SL levels. I would add that into the framework because it could, potentially, be used by any strategy. I'd use Input variables to turn it on/off and adjust levels.

Another way to look at it:

I have only one EA. All my code is OOP. When I want to test a new strategy, I simply extend my strategy class, plug it into my code base, compile, and I still have only one EA.

Thank you so much)