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'm trying to insert a piece of code in an automated strategy to limit my daily loss. Can someone share the code snippet that I can use for something like that? Thanks for your help.
Can you help answer these questions from other members on NexusFi?
[Description("Maximum loss (enter positive value!).")]
[Category("Parameters")]
[Gui.Design.DisplayName("\t\t\tMax Loss")]
publicint MaxLoss
{
get { return maxloss; }
set { maxloss = Math.Max(1, value); }
}
Beware that Historical will set your cumulated profit n loss just for the day (no good for backtesting),If you want both to be customized on strategy setup, you will have to set a bool variable on historical.
correct function is Performance.AllTrades.TradesPerformance.Currency.CumProfit without spacing (can't correct it)
Platform: TradeLink, OpenQuant, considering anything that works...
Trading: if it trades...
Posts: 94 since Oct 2010
Thanks Given: 24
Thanks Received: 39
Would a solution be to search the trade collection for trades that occurred that day, then add the current PnL?
You would obviously need to reset the dailyPnL each day.
It when then work regardless if you are in backtest or live trading. You would always be searching the trade collection based on the current day. Of course, please feel to poke holes in my logic