I just read this again, and I realised that you wanted coding information to create this indicator. These forums are to create fxdreema EAs, you need to go onto the MQL5 forums to get the information you require.
@ehsan1362
There isn't much more to say because money management should just be as simple as that. And invest enough to have a draw-down as close as possible to 100% but always below, so you optimize the gain and don't blow the account.
All the importance and the complexity lies in the ability of forecasting/predicting price moves. Up or down.
@Obis Luego de guardarlo en una variable cual seria el uso que le darias a ese valor, deberias compartir la idea completa amigo para comprenderlo mejor.