NexusFi: Find Your Edge


Home Menu

 





making a Performance.SessionTrades (sort of)


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one LostTrader with 2 posts (2 thanks)
    2. looks_two Adamus with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 2,002 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 2 attachments




 
Search this Thread

making a Performance.SessionTrades (sort of)

  #1 (permalink)
 
LostTrader's Avatar
 LostTrader 
Tucson, AZ
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Mirus/Zen-Fire
Trading: CL, TF
Posts: 74 since Sep 2009
Thanks Given: 21
Thanks Received: 64

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.

Attached Thumbnails
Click image for larger version

Name:	NT stc.png
Views:	165
Size:	18.6 KB
ID:	42244  
Attached Files
Elite Membership required to download: SessionTradeCollection.zip
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,442 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,602




Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
LostTrader's Avatar
 LostTrader 
Tucson, AZ
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Mirus/Zen-Fire
Trading: CL, TF
Posts: 74 since Sep 2009
Thanks Given: 21
Thanks Received: 64

LOL. Thanks, Mike!

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.

Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 
Adamus's Avatar
 Adamus 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, home-grown Java
Broker: IB/IQFeed
Trading: EUR/USD
Posts: 1,085 since Dec 2010
Thanks Given: 471
Thanks Received: 789


LostTrader View Post
LOL. Thanks, Mike!

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 hope NinjaTrader come up with the goods.

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.
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on July 5, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts