The quantiles of your trade statistics get to the heart of quantitatively setting rational stops and possibly even profit taking targets for a trading strategy or system. When applied to theoretical trades from a backtest, they may help to adjust parameters prior to trying the strategy with real money. When applied to real historical trades, they should help in examining what is working and where there is room for improvement in a trading system or strategy.

1 2 | ```
tradeQuantiles(Portfolio, Symbol, ..., scale = c("cash", "percent", "tick"),
probs = c(0.5, 0.75, 0.9, 0.95, 0.99, 1))
``` |

`Portfolio` |
string identifying the portfolio |

`Symbol` |
string identifying the symbol to examin trades for. If missing, the first symbol found in the |

`scale` |
string specifying 'cash', or 'percent' for percentage of investment, or 'tick' |

`probs` |
vector of probabilities for |

`...` |
any other passthrough parameters |

This function will use the `quantile`

function to calculate
quantiles of per-trade net P&L, MAE, and MFE using the output from
`perTradeStats`

. These quantiles are chosen by the `probs`

parameter and will be calculated for one or all of
'cash','percent',or 'tick', controlled by the `scale`

argument.
Quantiles will be calculated separately for trades that end positive (gains)
and trades that end negative (losses), and will be denoted
'pos' and 'neg',respectively.

Additionally, this function will return the MAE with respect to
the maximum cumulative P&L achieved for each `scale`

you request.
Tomasini&Jaekle recommend plotting MAE or MFE with respect to cumulative P&L
and choosing a stop or profit target in the 'stable region'. The reported
max should help the user to locate the stable region, perhaps mechanically.
There is room for improvement here, but this should give the user
information to work with in addition to the raw quantiles.
For example, it may make more sense to use the max of a loess or
kernel or other non-linear fit as the target point.

Brian G. Peterson

Tomasini, E. and Jaekle, U. *Trading Systems - A new approach to system development and portfolio optimisation* (ISBN 978-1-905641-79-6)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.