If your broker supports it and if you run more than 1 strategy, you might consider a stand-alone strategy that uses the GetAccountValue() method. You would need to manually enter your account value at the start of session as that method only works in OnBarDate.
You could then code a daily loss limit for that account, and a "trailing stop" on your equity curve that could trigger an alert or the FlattenEverything() command.
Just be careful if you invoke FlattenEverything() at the same time you are closing positions with other trade logic as you could get inflight issues. A way around it is to apply this stratgey to a different time series than the one you are trading on (say 3 minute bars, COBC=true, for example).
The following user says Thank You to MXASJ for this post:
Well I did play with the idea for a bit, but gave up after I realised that I could never get a strategy to do what I wanted.
the money management side was ok, but I couldn't get an strategy that I was happy with. So I gave up, and went back to trading manually. This was the main part of the code.
I am a very basic programmer, and tend to use code from other users, then change it a bit.
The following user says Thank You to vast for this post: