1 (edited by crifalo 2023-03-09 22:04:27)

Topic: compounding

Hi,
Do you know how I can add compounding in mql5 code in portfolio?
Best regards

Re: compounding

I don't know what compounding is. I searched it and found that "it makes you rich faster".

I'm not sure what exactly it means. Is it a form of scaling the entry amount?

We don't have such a feature in EA Studio.
Normally, the Account doesn't rise with a temp that needs automated scaling.

Re: compounding

He means position sizing based on account balance. Search the Forum, there are already implementations by others there.

Re: compounding

i found this code
the first is to compound interest and the second is to limit the spread

---esto va debajo del magic number------
extern bool compuesto     = true;
double capitalToCompuesto ;




---Esto va debajo del for en OrderSend------

if(compuesto && capitalToCompuesto > 0) amount = Entry_Amount*(AccountEquity()/ capitalToCompuesto);





---Esto va en el init---
capitalToCompuesto  = AccountEquity();

2

Input parameters section:

input int           Maximum_Spread_Points = 5;


----Esto va en OpenPosition Function ------


  if (!IsWithinMaxSpread())
        return;


-----Esto va debajo de todo el codigo es una funcion para el spread -----MT4-----

bool IsWithinMaxSpread()
{
    bool WithinMaxSpread = true;

    if (Maximum_Spread_Points > 0)
    {
        double spread = NormalizeDouble(((Ask - Bid) / _Point), 0);
        //Need NormalizeDouble here because of rounding errors in MT4 that otherwise occur (confirmed in several backtests).

        if (spread > Maximum_Spread_Points)
        {
            Print("El spread actual es de ", DoubleToString(spread, 0), " puntos, es mas alto del permitido que es ", DoubleToString(Maximum_Spread_Points, 0), " puntos. No realizara este trade!");
            WithinMaxSpread = false;
        }
    }

    return(WithinMaxSpread);
}
-------Funcion en MT5---------

bool IsWithinMaxSpread()
{
    bool WithinMaxSpread = true;

    if (Maximum_Spread_Points > 0)
{
    double spread = NormalizeDouble(((SymbolInfoDouble(_Symbol, SYMBOL_ASK) - SymbolInfoDouble(_Symbol, SYMBOL_BID)) / _Point), 0);
    // Es necesario utilizar NormalizeDouble aquí debido a errores de redondeo en MT4 que de otra manera ocurren (confirmado en varios backtests).

    if (spread > Maximum_Spread_Points)
    {
        Print("El spread actual es de ", DoubleToString(spread, 0), " puntos, es más alto del permitido que es ", DoubleToString(Maximum_Spread_Points, 0), " puntos. No se realizará este trade!");
        WithinMaxSpread = false;
    }
}

return WithinMaxSpread;
}

Re: compounding

I put this code to a portfolio with an RDD of 100 and limited to a spread of 5 and the results were extraordinary, even hard to believe hahahah.

Re: compounding

Thanks for sharing kitomc.

Could you perhaps post the full code for one of your portfolios? For a newbie in MT Coding like me, it's awesome to have something as a reference.

Re: compounding

geektrader wrote:

He means position sizing based on account balance. Search the Forum, there are already implementations by others there.

Exactly smile

Re: compounding

Popov wrote:

I don't know what compounding is. I searched it and found that "it makes you rich faster".

I'm not sure what exactly it means. Is it a form of scaling the entry amount?

We don't have such a feature in EA Studio.
Normally, the Account doesn't rise with a temp that needs automated scaling.


Yess it's scaling the entry amount. I would love to have that feature added.