Calculating preliminary profit factor

 

Hi guys,

I'm trying to calculate my Preliminary Profit Factor for my EA, but I think I must be going wrong somewhere, because its coming out at less than 1.0, but the EA is profitable.

My formula is: 

PPF = (winning_percentage / (100 -  winning_percentage )) * (reward / risk)

Now, I've just set reward to the take-profit value and risk to stop-loss.

I'm running through all the order history to calculate the winning percentage - my EA does delete a few pending orders, so I have to filter out order which aren't filled:

double profit=0, loss=0;
double total=0;

for(int i=0; i<OrdersHistoryTotal(); i++) 
{
        if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
        {
                if (OrderClosePrice() != 0)
                {
                        if (OrderProfit() > 0)
                        {
                                profit++;
                        }
                        else
                        {
                                loss++;
                        }
                        
                        total++;
                }
        }
}
double winPercentage = 100*profit / total;

This all gets called inside deinit().

I've got a winning percentage of 1.89% according to the test run. Am I detecting non-deleted orders correctly?

Cheers, Paul. 

 
monsterer:

Hi guys,

I'm trying to calculate my Preliminary Profit Factor for my EA, but I think I must be going wrong somewhere, because its coming out at less than 1.0, but the EA is profitable.

My formula is: 

PPF = (winning_percentage / (100 -  winning_percentage )) * (reward / risk)


I've never used this calculation so I'm just going by what you have written . .  but I assume that   reward is average win  and risk is the average loss,  not the number of winners and losers.
Reason: