NinjaTrader Crash Recovery - NinjaTrader Programming | futures io social day trading
futures io futures trading


NinjaTrader Crash Recovery
Updated: Views / Replies:3,430 / 12
Created: by TraderDJB Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

NinjaTrader Crash Recovery

  #1 (permalink)
Elite Member
Michigan
 
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

NinjaTrader Crash Recovery

In testing and using NinjaTrader, there have been many times that it has crashed on me. If I'm running a strategy live and NT or the computer crash, I'm concerned that I'll have to manually close open positions and then restart the strategy. Have any of you had experiences like this? Is there a way to allow the strategy to keep going where it left off?

I've been thinking, if I could reload the IOrders during "protected override void OnStart()" (only called right before the strategy goes live, after it does the quick backtest on the Days2Load), the strategy could continue where it left off. It wouldn't be hard to have all "!= null" IOrders printed into an XML file every 5 minutes using the code attached, or to read the file if "bool recoverPastTrades == true" but... IOrders are a read only interface, and not a class. That's where my programming ability ends - does this sound like a good idea? How could I create a new IOrder without actually sending it from "EnterOrder()"?

Oh, and it would want to check that the sum of all IOrders.Filled in the file == Account current quantity - in case an order was generated that didn't make it into the file and handle it if one didn't.

- DJB

Do or do not, there is no try. - Yoda
Attached Files
Register to download File Type: zip H2Configurator.zip (31.5 KB, 19 views)
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Florida
 
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
 
Posts: 456 since Jun 2009
Thanks: 1,359 given, 383 received


DJB -

No idea if this would be something that could help or if you already used it. Your programming with dlls is way beyond my capability...

 
Code

RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;

Good luck with your solution, whatever it may be.

Kirk

Reply With Quote
 
  #4 (permalink)
Elite Member
Michigan
 
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

Thank you for your input. That helps in terms of keeping it going, but what I'm talking about is restoring it if the worst happens - NT completely crashes. We'll see.

Do or do not, there is no try. - Yoda
Reply With Quote
 
  #5 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Are you on NT7? FWIW I'm finding the following is good to help prevent a crash:

- If I'm doing a lot of coding/compiling through the day memory usage increases and is not released. A fresh restart of Ninja is a Best Practice before going live. The same would apply for Backtesting (ie if you have been backtesting all day its worth a restart before going live).
- If I'm live and for some reason I have to do a lot of disable/enable with Strats, memory usage increases and is not released. I may restart Ninja at an appropriate time during the trading session.
- A daily or weekly reboot of the host PC is a Best Practice.

I'm considering adding some code to a Strat that will monitor memory usage every n time period and alert me if a threshold is crossed. That would allow me to flatten/restart to prevent a crash while I'm live.

I haven't had to do this yet (luckily!), but if I had a crash and I had any positions on that were not long term, I'd call the broker and direct them to flatten everything.

Memory usage in NT7 is my pet project this week . I'm trying both forced Garbage Collection and looking at which methods have a Dispose() thing going and how to take advantge of that. Also starting to wonder if its time to move to a 64 bit platform...

Reply With Quote
 
  #6 (permalink)
Trading for Fun
College Point, NY (Queens)
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: AMP/CQG
Favorite Futures: YM
 
Posts: 63 since Nov 2009
Thanks: 5 given, 20 received

Typically, for a crash such as you describe, you would have the exchange send over the orders, with their current state. You'd then have the correct state of each, etc. This is similar to a reconciliation. Re-loading anything on the client side w/o access to the destination (i.e. w/o consulting the exchange of record) does not reflect the current state of the orders.

Reply With Quote
 
  #7 (permalink)
Elite Member
Michigan
 
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

Thank you, both of you.

MXASJ, please do share with what you come up with for the memory freeing functions - I use all 64 bit and NT still does the same in terms of accumulating memory being used.

kandlekid, I'm looking into getting the orders from the broker that are active through NT - it's not official supported, supposedly.

Do or do not, there is no try. - Yoda
Reply With Quote
 
  #8 (permalink)
Elite Member
Michigan
 
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

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:

 
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++)
                {
                    Test.MoveNext();
                    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.

Do or do not, there is no try. - Yoda
Reply With Quote
 
  #9 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 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:

 
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++)
                {
                    Test.MoveNext();
                    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.

Very interesting...

If you are wondering about memory consumtion, try this in OnStartUp() and enable/diable a few times:

 
Code
                            
Print("Strategies in cache: " Account.Strategies.Count);
System.Collections.IEnumerator Test2 Account.Strategies.GetEnumerator();
for (
int i 0Account.Strategies.Counti++)
{
Test2.MoveNext();
Print(
"Current Strategies: " Test2.Current);


Reply With Quote
 
  #10 (permalink)
Elite Member
Michigan
 
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


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

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

Reply



futures io > > > > > NinjaTrader Crash Recovery

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

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


All times are GMT -4. The time now is 09:14 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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 2017-12-13 in 0.13 seconds with 20 queries on phoenix via your IP 54.82.56.95