Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am attaching your requested optimizer type. The new score considers Max Profit, SQN, Trades per Day, and the ratio of Long Profit to Short Profit.
There is one variable in there for the Long/Short Profit that is easy to change. I was not sure how sensitive you wanted this metric to be. I left comments in explaining.
//This value represents the floor to a divisor representing long short profit split
//0.1 = (60/40 split = 50/50 split = 40/60 split) performance would be halved at (70/30, 30/70)
//For a value of 0.05 (55/45 split = 50/50 split = 45/55 split)
//performance would be halved at (60/40, 40/60)
double rngLongShortBalance = 0.1;
//Actual calculation so that you can see what I am dividing by in the final output.
double rngLSbalance = Math.Max(rngLongShortBalance, Math.Abs(0.5 - (totLongProfit / totProfit)));
Basically, I thought you could use that variable to to set your own acceptable range outside of which there are reductions in the final score.
Otherwise the final score looks like this:
(SQN * Max Profit * Trades per Day) / (Long Short Ratio derivative)
To install place attached file in:
NinjaTrader7\bin\Custom\Type
Open Ninja Trader editor and compile any indicator or strategy
I am also going to take a look at the idea you mentioned about variation around a smooth upward sloping profit line as a possible improvement to the SQN number. Right now I can't visualize if that is going to be an improvement or end up causing problems somewhere.
I am attaching the Perfect Equity Curve (PEC) variants as well.
PEC
PEC * Max Profit
(PEC * Max Profit * Trades per Day) / (Long Short ratio derivative)
I would stay with the SQN and variants. The PEC versions truly do favor smoother curves at the expense of many other considerations. This ended up mostly an academic exercise, and I am posting just for anyone that is curious. Though I guess it could be used to check a smaller optimization field once the larger population has been narrowed down.
For example, I optimized one variable on my bot with just PEC. Usually the top few choices run from 58k-63k profit. Pure PEC gave me 22k for the first three, then got to some in the mid to upper 50k.
Thanks for this. What kind of sample size and trade frequency did you use in your test? I can imagine the fewer the trades, the more this will not make any sense.
It was small numbers compared to what I know you are planning...lol
Range was from 60 to 170 trades for those weird results. The PEC results in general, even for the variants, are certainly much more rigid than SQN. Instead of comparing to trade results to average profit and compiling, you are comparing current cumulative profit to where current cumulative profit should be based on average profit (average profit * trade number) and compiling. Effectively the variance can accrue trade to trade.
So far the PEC model seems to be performing very well. I am still wet behind the ears when it comes to Ninja and C#, I am having to re-learn stuff all over again after being out of it for years. But it seems that your code works. Once I get some more complex strategies converted, I'll know for sure
In my testing, the PEC model produces quicker [genetic time] and more desirable results than the other SQN types you provided.
Looking forward to it, and really want to thank you again.
The source was posted already, MultiCharts uses C# for its optimizer type thing (whatever it is called). They don't document anything, so good luck finding the right keywords. It is not EasyLanguage.
It was in the original SQN code so I left it. If there are less than 30 trades, then SQN returns zero due to too small of a sample. I think that part also checks the number of parameters in the strategy and if there are more than 30, then that number becomes the floor.
I could be totally wrong. It would be nice to have someone who is a better coder to evaluate that section because it may just be wasting cpu cycles.