NinjaTrader Crash Recovery (Page 2) - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

NinjaTrader Crash Recovery
Started:July 13th, 2010 (01:45 PM) by TraderDJB Views / Replies:2,881 / 12
Last Reply:August 18th, 2010 (05:26 PM) Attachments:1

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

NinjaTrader Crash Recovery

Old July 16th, 2010, 11:38 AM   #11 (permalink)
Elite Member
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 798 since Jun 2009
Thanks: 109 given, 784 received

TraderDJB View Post
Right, that's the info displayed in the control panel tabs.

You will see an instance in cache (for want of a better word) for every enable/disable/enable cycle of each strategy, and GC does not clear it.

Reply With Quote

Old July 23rd, 2010, 11:02 AM   #12 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: NinjaTrader, TradeStation, Thinkorswim
Broker/Data: MB Trading
Favorite Futures: Forex
TraderDJB's Avatar
Posts: 46 since Jan 2010
Thanks: 7 given, 28 received

I've been trying to get to the list produced by the Strategy Analyzer in a similar fashion to no avail, as well as...

// There is only 1 in this.Strategies, so this doesn't work...
//foreach (StrategyBase strategy in this.Strategies)
// Strategy.Print("Profit Factor: " + strategy.Performance.AllTrades.TradesPerformance.ProfitFactor);

Have you had any success in this?

Do or do not, there is no try. - Yoda
Reply With Quote

Old August 18th, 2010, 05:26 PM   #13 (permalink)
Just starting out...
Futures Experience: Intermediate
Platform: MT4, NT7
Posts: 4 since Aug 2010
Thanks: 1 given, 0 received

TraderDJB View Post
Update: I have successfully accessed from within the strategy the global values that are listed in the Executions, Positions, and Accounts tabs using this code:

// To access Executions or Accounts, replace "Positions" with the appropriate change.
                Print("Positions: " + Account.Positions.Count);
                System.Collections.IEnumerator Test = Account.Positions.GetEnumerator();
                for (int i = 0; i < Account.Positions.Count; i++)
                    Print("Current" + Test.Current);
It seems that the current status of the broker isn't kept into separate orders that the strategy placed but rather is the running sum. So, I'll have to have the strategy infer based on the current quantity and direction (long/short) where it is at then it will know for sure. Since it uses multiple orders of fixed sizes, it won't be hard to infer how many it has active to match the broker position.

It still doesn't solve how to recreate the IOrder... but I suppose the strategy doesn't need to, it could keep track at that point by something else instead of IOrder == null...... more updates to come.

Interesting thread and it's something that has been on my mind as I've been trying to learn NT7 over the last few weeks. This stuff is important not just for crash handling but in the event of power failure/etc too where you want to resume the trade. After NT7 restarts after a crash/reboot, will the strategy remain in the Strategies tab and be checked Enabled?

Bear in mind I'm still new to NT and maybe this is new to NT7 also but I can see Account.Orders in there which is an OrderCollection. Give that you know already (or at least you should!) what the order signal name is for a given strategy you should be able to query each order in the collection, match its status and signal name to retrieve it.

In this code example I'm just guessing that you can cast to IOrder from the OrderCollection. When I did backtesting using the following code I found the count was always 0, which I suppose is understandable for a backtest, but it didn't really answer my question properly. Maybe someone with a live trading account can give it a shot?

System.Collections.IEnumerator Test = Account.Orders.GetEnumerator();
                for (int i = 0; i < Account.Orders.Count; i++)
                    IOrder TestOrder = (IOrder) Test.Current;
                    Print("Current " + Test.Current);
Aside from that I'm being careful to avoid any loose-hanging variables that are set on the fly that would need to be re-filled during the OnStartUp() after you've got the orders back out of the collection. And personally I don't really like that practice anyway.

Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > NinjaTrader Crash Recovery

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash Crash Documentary Ryanb Traders Hideout 5 April 22nd, 2015 10:10 AM
Was Last May's 'Flash Crash' Actually Caused by the SEC? Quick Summary News and Current Events 0 September 15th, 2010 11:50 AM
NT7 Problem after Computer Crash britkid99 NinjaTrader 13 August 23rd, 2010 05:35 PM
Why many knew about the crash a few weeks back .... webart The Elite Circle 7 June 2nd, 2010 04:38 PM
Happy 80th birthday 1929 crash shodson Traders Hideout 0 October 27th, 2009 04:01 PM

All times are GMT -4. The time now is 06:26 AM.

Copyright © 2016 by 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.
no new posts

Page generated 2016-10-28 in 0.08 seconds with 20 queries on phoenix via your IP