Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Only trade if win rate of past 10 trades is >= mean win rate

Currently my algo trades daily if it satisfies my conditions.

  1. What I would like to do is record the running win/loss (WL) count array for each trade.
  2. Then get a mean WL/count.
  3. Then set a rule, only trade if WL rate of past 10 trades is >= mean WL rate (or simple a constant e.g. 0.5*meanWL rate)

Catch being, if these conditions are satisfied once, my algo will never trade for the remainder of my backtest.

So what I need to do is record the actual WL of every trade placed, and then if the WL rate conditions is satisfied (ie I dont trade due to last WL rate of last 10 trades being too low) I need to record theoretical trades, ie what would have occured if I did trade, so the running WL count array is continually adjusted.

Any ideas?

2 responses

Thanks Karl,this is way better thank you!
Is their any way of doing this on quantopian?
I am not sure how to check performance of trades

Ahh nice work!