I feel like this should be an easy one but seeing as I’m normally fairly adept on PRT I think I’m either massively overthinking it or its just impossible (ha!) So here goes;
I have a trend following system that on any given day produces trade results heavily inline with previous trades of the same day (Z-score of -31!). Great when it’s profiting, awful when its losing. To combat this I want to stop the system trading for the rest of that trading day (only) after an arbitrary number of losing trades (we’ll use 3 but once I have the code I’ll clearly refine this).
I’m assuming the ideal code would look something like this;
The issue is of course, that neither a TradeDate function, or Position/Trade number function exists (unless I just can’t find it?). I can of course figure out how to stop it running based on the past three trades being losing trades, however the important part is these trades are only relevant if on the current trading day.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.