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've asked NT for a TradeCollection of Performance.SessionTrades only but they don't have one.
So I am trying to finagle one up. I've gotten this far -- it works for me but I only ever trade one contract.
I've attached code which was extracted from my actual Strategy -- so don't think this code is a working Strategy!!! there are no entries. It merely provided a way to port the components needed.
Everything relevant is tied to the variable sessionTrades.
private TradeCollection sessionTrades;
I had to dummy up a constructor in OnStartUp(), and a reset function (same dummy code).
sessionTrades = Performance.RealtimeTrades.GetTrades(Instrument.MasterInstrument.Name, " ", 0);
I add the last trade to sessionTrades in OnPositionUpdate() when flat. I do not know if this is best, although it seems to work for 1 contract only.
sessionTrades.Add(Performance.AllTrades[Performance.AllTrades.Count - 1]); // adds a link, does not copy
At FirstBarOfSession, it prints statistics and resets the TradeCollection for the new session.
I am sharing as there are many programmers better than I and thought some-one could help improve it.
Like, how does it need to change for multiple contracts? legging in or out ?
Because when a single position has multiple trades, this will break down, I think.
It's weird, NT Support says the TradeCollection is updated after OnPositionUpDate() which seems illogical to me, and the code I wrote looks during OnPositionUpDate() and finds that just closed trade. But they say it isn't reliable. Lovely.
So I made a formal request (#1095) for them to create the Performance.SessionTrades. We'll see how long it takes.
I am not surprised that the TradeCollection is updated after the OnPositionUpdate event. I recently read a thread on the NT support forum describing an issue related to this. They only put finished trades into the Performance trade collections, so it follows that this will only happen after an exit has caused the OnPositionUpdate event to fire.
Sorry that I can't help with the problem. I've come up against this kind of requirement before and in my experience, trying to solve it is a bit like trying to nail sh*t to a wall, if you'll excuse the expression. So I just live without it. And try not to let it get to me .
You can discover what your enemy fears most by observing the means he uses to frighten you.