Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

!Historical not working

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

    !Historical not working

    I had a strategy that worked perfectly.

    I had some pieces of code that can only be executed for non historical bars. Today !Historical doesn't seem to work. Code under !Historical conditional is executed even on historical bars.

    I uninstalled ninja and reinstalled completely. I Repaired the database and deleted the content of the cache folder.

    Any help?

    Thanks

    #2
    Hello guillembm,

    Thanks for your note.

    I am unable to reproduce this behavior.

    Attached is a simple test script that draws a dot on every real time bar that closes.

    Does this script draw dots on historical data on your machine?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      This test works on the chart. But if I apply this code on a strategy this is what I get:

      ---------------------------------------------------------
      if (!Historical)
      Print ("no historical"+ "#" + ToDay(Time[0]) + "#" + ToTime(Time[0]));
      else
      Print ("historical"+ "#" + ToDay(Time[0]) + "#" + ToTime(Time[0]));
      -----------------------------------------------------

      The result is :

      no historical#20140520#154800
      no historical#20140520#174000
      no historical#20140520#193200
      no historical#20140520#212400
      no historical#20140520#230000
      no historical#20140521#5200
      no historical#20140521#24400
      no historical#20140521#43600
      no historical#20140521#62800
      no historical#20140521#82000
      no historical#20140521#101200
      no historical#20140521#120400
      no historical#20140521#135600
      no historical#20140521#154800


      It seems that ninja is not recognizing the historical/non-historical flag on a bar

      Comment


        #4
        Hello guillembm,

        Please export a sample script that is able to reproduce this issue and attach this to your next post.

        To export your script do the following:
        1. Click File -> Utilities -> Export NinjaScript
        2. Enter a unique name for the file in the value for 'File name:'
        3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
        4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


        Below is a link to the help guide on Exporting NinjaScripts.
        http://www.ninjatrader.com/support/h...nt7/export.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I just discovered the cause. I created another strategy and copy-pasted each piece of code till the error was replicated. On Initialize() I have this code:

          protected override void Initialize()
          {
          Add(PeriodType.Tick, 1);
          Add(PeriodType.Second, 4);

          Instr = Instrument.FullName;
          Currency1 = Instr.Substring(1,3);
          Currency2 = Instr.Substring(4);


          //TraceOrders = true;
          Unmanaged = true;
          IgnoreOverFill = true;
          CalculateOnBarClose = false;
          RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
          ConnectionLossHandling = ConnectionLossHandling.KeepRunning;
          }

          The cause is the time frame Adds

          Add(PeriodType.Tick, 1);
          Add(PeriodType.Second, 4);

          When erasing these Add, ninja reacts correctly.

          Comment


            #6
            I've been working on this error and there is a new related issue.

            After starting ninja and executing the strategy it loads data from any previous day. After this, without deleting the Add(), the next time the strategy is executed it only loads data from the same day (today's).

            My provider is IB, if this helps

            Comment


              #7
              Hi guillembm,

              The data should be loading from the first day in the Days to load.

              Are you saying that after disabling and re-enabling the script is not processing any historical data?

              Do you have a simplified strategy that demonstrates this?

              Are you printing the current bar number and time of the bar in the script to see on which bar it starts?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                !Historical not working

                I attach a simple strategy that reproduces this error.

                It doesn't happen when enabling the first time but on the second or third time. Only bars since 20140618 are loaded.

                DaysToLoad is set to 5 on my ninja
                Attached Files

                Comment


                  #9
                  Hi guillembm,

                  You are printing a ton of information to the Output window which has a limit to the number of lines it will show.

                  Are you seeing a message in the output window that reads "You have reached the maximum threshold of the Output window. Some of your output messages have been surpressed."? (I am getting this message)

                  You are currently printing every primary bar, every tick, and every second.

                  I added
                  if (BarsInProgress != 1 || CurrentBar % 20 > 0)
                  return;

                  To the beginning of OnBarUpdate to limit the number of bars shown. This only shows prints from the tick series and will only show every 10th bar. I am seeing data back to the 13th on the ES 09-14.

                  In other words you are printing to much for the output window.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I don't receive this message.

                    Even adding this code you sent the result is the same. If I don't comment the Add() lines only data for the present day is loaded. Without Add() everything goes fine

                    I think the output window can display enough lines to show this. I tried to reproduce it in another PC and the result is the same.

                    I also tried to put:

                    if (BarsInProgress != 0)
                    return;

                    with the same result.

                    But experimenting I found that using this it works:

                    Add(PeriodType.Tick, 1);
                    Add(PeriodType.Second, 4);

                    //Unmanaged = true;
                    //IgnoreOverFill = true;
                    CalculateOnBarClose = false;
                    //RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
                    //ConnectionLossHandling = ConnectionLossHandling.KeepRunning;

                    I only left CalculateOnBarClose = false; uncommented

                    Comment


                      #11
                      Hi guillembm,

                      Attached is the script modified, and the output from an ES 09-14 chart with 5 days to load.
                      Attached Files
                      Last edited by NinjaTrader_ChelseaB; 06-18-2014, 10:00 AM.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by agclub, 04-21-2024, 08:57 PM
                      4 responses
                      18 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by Irukandji, Today, 04:58 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post Irukandji  
                      Started by fitspressoburnfat, Today, 04:25 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post fitspressoburnfat  
                      Started by Skifree, Today, 03:41 AM
                      1 response
                      4 views
                      0 likes
                      Last Post Skifree
                      by Skifree
                       
                      Started by usazencort, Today, 01:16 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post usazencort  
                      Working...
                      X