Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on restart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Error on restart

    I was running a strategy on 6 different products, all will positions. I knocked the the powercord, shutting down my pc. I powered up again and restarted ninja, all the positions that were there before the PC shut down were still there, so no problems there. I then restarted the strategies and 5 of them picked up where they left off, their positions matching what I had in my positions page, except for 1. It was listed as flat while it should have been 1 contract short. When it hit my reverse price the actual position reversed to 1 long as it should, but the strategy read 2 long now.
    I checked and double checked the settings, stopped and restarted. I even checked on the chart, which clearly shows the trade. Is this a common occurance, or am I doing something wrong?

    Thanks

    #2
    maninjapan, sounds like you got out of sync with one strategy / instrument at the time you lost power / connection, could it be it missing a point to reverse and thus had improper size for the next trade you saw then realtime?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Im not sure why it was out of sync though. All the others came back fine. Its a 30 minute break out system, when I restarted it it should have been showing Short 1, but it was showing flat in the strategy positions column ( the position page showed short 1), when it reveresed it bought to cover and entered a new buy, giving me 2 long. The output window shows the high/low for the 1st 30 minutes as expected, and the entry is on the chart. It even bought to close the position, only thing is, the strategy position column showed flat......

      Comment


        #4
        maninjapan, it may have been a database corruption issue, because of the sudden power failure, it would be helpful to review your trace and logs files, you can send them in using the Help > Mail to Support feature.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks, just sent them

          Comment


            #6
            Guys, a different problem ,but with the same strategy. I was running it again today on a basket of futures and stocks. All of them matched my manual calculations except 1 symbol, NG.
            The strategy is a variation of a 30 minutes Breakout with reversal, so after the first entry, it is in the market until the end of the day.
            Except in this case, it entered long, retraced to the reversal point, instead of going short, it just closed out. Right price, but only 1 sell instead of 2.
            funny thing is though when I stopped and started the strategy it was showing 1 Short.
            Then after it retraced again to the reversal point it didnt even close out the position, just stayed short. I stopped and started the strategy again and then it showed the correct position of 1 Long. Its as if it is reading the historical data correctly but not reacting in real time.
            This is about the 3rd time I have had this problem and it is always with the NG contract.


            Any thoughts?

            Comment


              #7
              maninjapan, and you're sure synching wise all was correct for the NG strategy? From your post it seems like it starts flat each day...

              Also: which broker do you use as you experience this?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                yes, it starts flat at the beginning of the day, it made the first long entry fine, and should have reversed to a short position, but went flat.
                I am connecting to TWS.
                here is a copy of the code if that helps
                Code:
                // 
                // Copyright (C) 2007, NinjaTrader LLC <www.ninjatrader.com>.
                // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
                //
                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Diagnostics;
                using System.Drawing;
                using System.Drawing.Drawing2D;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Data;
                using NinjaTrader.Indicator;
                using NinjaTrader.Strategy;
                #endregion
                
                // This namespace holds all strategies and is required. Do not change it.
                namespace NinjaTrader.Strategy
                {
                    /// <summary>
                    /// Simple strategy that monitors for a breakout.
                    /// </summary>
                    [Description("Simple strategy that monitors for a breakout.")]
                    public class Gyau30minutebreak: Strategy
                    {
                        #region Variables
                        private double highestHigh    = 0;
                        private double lowestLow    = 0; 
                        #endregion
                
                        /// <summary>
                        /// This method is used to configure the strategy and is called once before any strategy method is called.
                        /// </summary>
                        protected override void Initialize()
                        {
                            CalculateOnBarClose = true;
                        }
                
                        /// <summary>
                        /// Called on each bar update event (incoming tick)
                        /// </summary>
                        protected override void OnBarUpdate()
                            
                    
                        {
                            
                            
                            // Resets the highest high and lowest low at the start of every new session
                            if (Bars.FirstBarOfSession && FirstTickOfBar)
                            {
                                highestHigh = High[0];
                                lowestLow    = Low[0];
                            }
                        
                            
                            // Stores the highest high from the first 30 minutes on a 5 minute chart
                            if (Bars.BarsSinceSession < 6 && High[0] > highestHigh)
                                highestHigh = High[0];
                            // Stores the lowest low from the first 30 30 minutes on a 5 minute chart
                            if (Bars.BarsSinceSession < 6 && Low[0] < lowestLow)
                                lowestLow    = Low[0];
                            // Prints details in the output window to follow for confirmation    
                                Print(Instrument.FullName + " " + Time[0] + " " + CurrentBar + " " + highestHigh + " " + lowestLow);
                                Print(Bars.BarsSinceSession);
                            // Draw the bar count on the chart
                                DrawText(CurrentBar.ToString(),Bars.BarsSinceSession.ToString(),0,High[0] + (TickSize *3),Color.Blue);
                            
                            
                            
                            //Print the symbol and Highs and Lows of the first 30 minutes 
                            if (Bars.BarsSinceSession == 5 )
                                PrintWithTimeStamp(Instrument.FullName + " " + "High" + " " + highestHigh + " " + "Low" + lowestLow);
                                
                            
                        
                            
                             //Setup the Stop in the direction of  close to the high/low midpoint
                             if (Bars.BarsSinceSession >= 5 && Close[0] > (highestHigh + lowestLow)/2)
                                //Enter Long at highest high + 1 of first 30 min.
                    
                                 EnterShortLimit(DefaultQuantity, highestHigh + TickSize, "");
                                //} PrintWithTimeStamp(Instrument.FullName + " " +) 
                                    
                            else if (Bars.BarsSinceSession >= 5 && Close[0] < (highestHigh + lowestLow)/2)
                                //Enter Short at lowest low - 1 of first 30 min.
                             
                                EnterLongLimit(DefaultQuantity, lowestLow - TickSize, "");
                            
                        
                        
                        
                            
                        }
                        
                    }
                    
                }

                Comment


                  #9
                  Ok, thanks for the code, I see nothing suspicious regarding the issues you report in - are you on TWS 898 with NT 6.5.1000.14?

                  Also there are CL / NG related issues with the IB API, I suggest you check into this thread, the position might be recorded for another expiry as you would expect - http://www.ninjatrader-support2.com/...ad.php?t=16341
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Wow, looks like I've flown into a real sh!t storm on this one. Good thing I can still run this thing manually....

                    Btw, yes I am running the latest version of both here....

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by WHICKED, Today, 12:56 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post WHICKED
                    by WHICKED
                     
                    Started by Spiderbird, Today, 12:15 PM
                    2 responses
                    10 views
                    0 likes
                    Last Post Spiderbird  
                    Started by WHICKED, Today, 12:45 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post WHICKED
                    by WHICKED
                     
                    Started by FrazMann, Today, 11:21 AM
                    2 responses
                    6 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Started by rjbtrade1, 11-30-2023, 04:38 PM
                    2 responses
                    80 views
                    0 likes
                    Last Post DavidHP
                    by DavidHP
                     
                    Working...
                    X