When evaluating the success of a trading strategy, a strategy developer can use a large number of strategy metrics. One of them is the profit factor. Profit Factor may be defined as:
The profit factor is defined as the gross profit divided by the gross loss (including commissions) for the entire trading period. This performance metric refers to the amount of profit per unit of risk, with values greater than one indicating a profitable system.2 For example, the strategy performance report shown in Figure 1 indicates that the trading system tested has a profit factor of 1.98.
This is calculated by dividing the gross profit by the gross loss:
$149,020 ÷ $75,215 = 1.98
Source: https://www.investopedia.com
It is a simple, robust, and standardized metric. In the book Statistical Sound Indicators For Financial Market Prediction, author Timothy Masters has developed a new method for calculating the profit factor. Let me quote directly from his book
Suppose that a position is taken and maintained for five bars. And the following sequence of individual bar return is obtained : +1 +3 -2 -2 +1 . Then we have string of returns Then we have one more sting of returns from a position taken and maintained later: +2,-,,+1. Recall that the profit factor is feined as the sum of winds divided by the sum of lossed. With my method we have (+1,+3,+1,+2,1)/(2+2,+3) = 8/7 = 1,14 This is worthlessly small profit factor , which is not at all surprising since the net gain +1. But if you were the topool each of those two contiguous positions, there would be two trades with a profit factor of 1/0 or infinite and seriously unstable overestimate of true probability of the system.
Master s Profit factor is calculated as the log ratio of open price of the current bar compared to the open price of the previous bar.
This snippet can be calculated thanks to the newly added ability to work with historical data in the upcoming version 136. When calculating the strategy metrics, we work with the orderlist class which stores the values of the given trades. Until now we didn’t have access to time series data before/during the trades, but thanks to the History Class loader we have.
You can find more information about this method in our blog post here
This method does not work for protected data ( futures and stocks ) from Barchart. It is important to note that working with data snippets is slower because the HistoryClass loading class is not so fast
You can download the databank snippet here.

Good idea !!!!! Thank you Clonex
I tried to install the snipped and sqx 137 stopped working, had to unintall….