Topic: How can I apply compound interest to portfolios?

Hi everyone, how can I apply compound interest to portfolios? any code for this?

Re: How can I apply compound interest to portfolios?

Please contribute more to what you need.

Re: How can I apply compound interest to portfolios?

Hello everyone, I created a specific video (in Italian), a few months ago, on how to embed the Compounding Effect on Portfolios and EAs generated with EA Studio.

4 (edited by bobstar 2024-08-02 20:43:01)

Re: How can I apply compound interest to portfolios?

For simplicity, I'll write you here the steps, so that you can apply them to MQL4 and MQL5 codes:

For MQL5

1) First step, put these 2 lines at the beginning, close to the global variables:

double capitalToCompound = AccountInfoDouble(ACCOUNT_BALANCE);
         input bool      compounding            =      true; // Compounding

Compounding effect - phase 1.png


2) Second step, put these lines in OpenPosition function just before ManageOrderSend, and replace "EntryAmount" with "amount" variable in the ManageOrderSend function.

double amount = Entry_Amount;
   if(compounding && capitalToCompound > 0) amount = Entry_Amount*(AccountInfoDouble(ACCOUNT_EQUITY)/capitalToCompound);
   amount = NormalizeDouble(amount,2);

Compounding effect - phase 2.png


--------------

For MQL4, the procedure is similar; the first step is identical to the MQL5.
The second step is basically modifying the "amount" variable, here's the code:

if(compounding && capitalToCompound > 0) amount = Entry_Amount*(AccountInfoDouble(ACCOUNT_EQUITY)/capitalToCompound);
   amount = NormalizeDouble(amount,2);

Compounding effect - phase 2 MQL4.png


-----------
It's not necessary to initialize the "capitalToCompound" variable in OnInit, because it's already initialized in the global variables when created.

....this is it! How to embed the "Compounding Effect", fully explained!

...Enjoy!

Post's attachments

Compounding effect - phase 1.png
Compounding effect - phase 1.png 24.39 kb, 2 downloads since 2024-08-02 

Compounding effect - phase 2 MQL4.png 44.72 kb, file has never been downloaded. 

Compounding effect - phase 2.png 21.28 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: How can I apply compound interest to portfolios?

It is still a big question for me why there is no desire to add the % close to Lots as in Builder. I asked for this a long time ago. Maybe this is just a marketing strategy. Anyway, even with the Lots option only, the Experts Advisors Studio is fantastic. Thank you Mr Popov.

6 (edited by kitomc 2024-10-24 12:08:44)

Re: How can I apply compound interest to portfolios?

I want to share a script I developed to modify the code of an automated trading strategies portfolio. The main goal of this script is to efficiently update certain aspects of multiple strategies without having to do it manually.


Does exactly what this post says, just work in portfolio.

Post's attachments

Interes compuesto Portafolio.py 4.79 kb, 2 downloads since 2024-10-24 

You don't have the permssions to download the attachments of this post.