1 (edited by rantampla 2019-04-15 00:13:27)

Topic: Critical Error in Portfolio Test

Hi Miroslav,

have you a Idea for the attach Picture with error in Tester?

It comes after ~ 20.000 Trades.

Thanks, Marcus.

Post's attachments

error.png 111.08 kb, file has never been downloaded. 

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

Re: Critical Error in Portfolio Test

It says that the error is on line 632. Please copy the near lines to see what is there. It is probably some indicator.

3 (edited by rantampla 2019-04-15 09:04:29)

Re: Critical Error in Portfolio Test

Ich have now 608 to 671 copy.

Thank you smile

// $(__MT4TRACKER)
#define MAX_WINS_LOSSES  (2000)
char g_acWinsLosses[MAX_WINS_LOSSES];
int GetMagicStats(const int magicNumber, double& dWinRatio, int& iMaxConsecutiveLosses)
{
    dWinRatio = 0;
    iMaxConsecutiveLosses = 0;
    
    int iCountTrades = 0;
    for (int i = 0; i < MAX_WINS_LOSSES; i++)
    {
        g_acWinsLosses[i] = 0;
    }

    int total = OrdersHistoryTotal();
    for(int pos=total-1; pos>=0; pos--)
    {
        if((true == OrderSelect(pos, SELECT_BY_POS,MODE_HISTORY)) && (OrderSymbol() == _Symbol) && (OrderMagicNumber() == magicNumber))
        {
            // The net profit value (without swaps or commissions) for the selected order. 
            // For open orders, it is the current unrealized profit. For closed orders, it is the fixed profit.
            if (OrderProfit() >= 0)
                g_acWinsLosses[iCountTrades++] = 1;
            else 
                g_acWinsLosses[iCountTrades++] = 0;
        }
    }
          
    int iCountWins         = 0;
    int iCountLosses       = 0;
    int iConsecutiveLosses = 0;
    int iNRecentTrades     = 99999;
    if (Most_Recent_Trades > 0)
        iNRecentTrades = Most_Recent_Trades;
            
    if ((iCountTrades > 0) && (iCountTrades < iNRecentTrades))
    {
        for (int i = 0; i < iCountTrades; i++)
        {
            if (g_acWinsLosses[i] > 0)
            {
                iCountWins++;
                iConsecutiveLosses = 0;
            }
            else
            {
                iCountLosses++;
                iConsecutiveLosses++;
                if (iConsecutiveLosses > iMaxConsecutiveLosses)
                    iMaxConsecutiveLosses = iConsecutiveLosses;
            }
        }
        dWinRatio = (double)(iCountWins) / (double)(iCountTrades);
        // Print("INFO1: GetMagicStats: MagicNumber: ", IntegerToString(magicNumber), ", CountTrades: ", IntegerToString(iCountTrades), ", CountWins: ", IntegerToString(iCountWins), ", CountLosses: ", IntegerToString(iCountLosses));
    }
    else if (iCountTrades > 0)
    {
        for (int i = (iCountTrades-iNRecentTrades); i < iCountTrades; i++)
        {
            if (g_acWinsLosses[i] > 0)
            {
                iCountWins++;
                iConsecutiveLosses = 0;
            }

Re: Critical Error in Portfolio Test

If it is that one:

 g_acWinsLosses[iCountTrades++] = 1;

It is not our code.


Check the array initialization if have enough space.

Re: Critical Error in Portfolio Test

Popov wrote:

If it is that one:

 g_acWinsLosses[iCountTrades++] = 1;

It is not our code.


Check the array initialization if have enough space.

Yes, this the Code from Sleytus, from MT4-Tracker. I have thinked, you ok with this?

I dont understand, how i can do. But i see i must under 30.000 Trades.

Thanks