Extracting 80% of middle trades and counting average trade
30.10.2020 17.04

NinjaTrader 8 Backtesting Strategies Tutorial

NinjaCoding friend


I wanted to ask for your help in making custom Optimization Fitness strategy. I want to extract 80% of middle trades, that are first sorted by profit/loss and then calculate average per trade. 

To my mind, the process goes like this:

1) Take all trades

2) Sort by Profit/loss

3) Count trades in the list

4) Calculate 80% of total count

5) Extract middle 80% of trades from the list

6) Calculate average of those trades

But as coding is not my bread and butter, can you help here with a code?