Big Mike's Trading Blog

Day trading futures, discussing money management and trade management techniques, and more

NinjaTrader adapting code based on past trade performance

As you know, one of my goals is to write a strategy that is self-adapting. This can be incredibly complex, but here is one easier element to implement (below).


The idea of this code snippet is simple: If past trades are working, then push for more profits. If they are not working, cut the profits back.



The above code looks at the last long. You can change it to look at as many trades as you want, and weight them differently (maybe the most recent trade has more weight).

I use a scoring system to evaluate a trade before entering it and determine profit targets, above is a small snippet. I will write more on the Score function in another post.

You'll need to either pass "direction" (ie: Score(string direction)) or modify the code somewhat. The idea is not to give a cut/paste example, but instead to give you inspiration or an idea you had not previously considered.

I hope this can improve your trading!

Mike

3 comments:

duck said...

Hi Mike

Nice job on your blog...I am a Ninja user "duck_CA" that loves to tinker with codes. Would you be interested in looking at an Indicator that I have made which draws rectangles at a given Date and Time? I would like it as streamline at possible so it doesn't bog down my pc. I basically use it to store my entries so they don't get erased if I delete that chart.

Thank you

Mike said...

Hello duck,

I'm always interested in looking at new stuff, but am probably no help for optimizing it. I can program enough to get in trouble, but certainly not enough to be efficient! :)

Mike

zoltran said...

Hi Mike

Scoring looks like it would be useful with signals and filters as well.

For example, lets say we have 6 conditions we *like* to see for a setup, each one adding more weight or comfort. But we don't need all of them.

So if all 6 are there, we trade 2 contracts, but if only 4, then just 1, and if less than 3, we don't trade... sort of thig

Y

Post a Comment

Note: Only a member of this blog may post a comment.