Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

if(Historical) return;

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

    if(Historical) return;

    if(Historical) return;

    Hi guys, this statement isn't working, any ideas? When i moved my new strat to production it began to print historical print statements.

    #2
    Hello,

    Thank you for the question.

    Can you provide an example of this not working so that I can see how you have implemented this? Also how are you running the strategy, in live data or is this in market replay or on simulated data?

    In general this can be placed before any statements that do not need to be run Historically as you know, depending on the placement anything before it would still be run anything after would not.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I have 1 primary series and 2 secondary series in a strategy. When I move the strategy to production it continues to print out historical values from previous days. Primary series is 2 betterrenko. I just also tested it on the 1 minute and its the same effect.

      Comment


        #4
        Hello,

        Thank you for the reply.

        I have not experienced this when using the if(Historical) bool.

        If you can provide an example of this in code that produces the issue I would be happy to take a look at it and see what is happening.

        Without an example to see how this is happening I can only tell you that this is the correct syntax you are using and that preventing historical data from being used would be its use.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hey guys I think i may have found the cause of this error. It appears to occur when you refer to another dataseries while you are inside the 0 bar series that causes the historical statement to malfunction. Will post more info when I found the exact statement.

          Comment


            #6
            Hey guys this error just appears to be caused by adding more than 1 series to a strategy! hope you will be able to help me solve it here is the strategy as it stands now:

            Initialize:
            // Set calculation options
            CalculateOnBarClose = true;

            BarsRequired = 150;
            EntriesPerDirection = 3;

            Add("A", PeriodType.Minute, 1440);

            Add("ABC", PeriodType.Minute, 5);

            Add("ACT", PeriodType.Minute, 1);

            // Exit trade at end of session
            ExitOnClose = true;
            ExitOnCloseSeconds = 60;

            protected override void OnBarUpdate()
            {

            if(BarsInProgress==1)
            {
            if(Historical) return;
            }

            if(BarsInProgress==3)
            {
            if(Historical) return;
            }

            if(BarsInProgress==0)
            {
            if(Historical) return;
            }

            if(BarsInProgress==2)
            {
            if(Historical) return;
            }

            //THIS IS 5 MINUTE BAR SERIES
            if(BarsInProgress==2)
            {
            if(Historical) return;


            }


            if(BarsInProgress==0)
            {
            if(Historical) return;



            Print("this is a test for time series: " + Time[0]);




            } // END OF BAR 0
            }

            Comment


              #7
              As you can see, the print time statement should not be executing but it does in realtime, for example it prints from the bars from June today! Please advise.

              Comment


                #8
                Hello,

                In the code you have posted the print should be happening during live data because it is not historical data and that is what the condition is checking for.

                The if(Historical) return is returning for all historical bars and then when live data comes in it will allow the print.

                If you do not want something to happen in Live data you would want to use if(!Historical) or in English if not historical then

                I think you are looking for if(!Historical) return; this will not happen live if you do this.

                Please let me know if i may be of additional assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Sorry, but I think you have misunderstood, the statement below executes on both historical and real-time bars:

                  if(BarsInProgress==0)
                  {
                  if(!Historical)
                  {
                  Print("this is a test for time series: " + Time[0]);
                  }

                  }

                  Comment


                    #10
                    Hello,

                    The code you had provided previously did not include this statement, and I have replied based on the code you provided.

                    In the new statement you provided I have tested this and yes your findings are correct. It would seem that the added bar series is not getting a request for historical data. This is a known limitation when adding multiple data series. In certain cases the historical data is not loaded so there are no historical bars to process.

                    The resolution I have found was to Open a chart with the instruments you are adding and request historical data so that it is downloaded.

                    Here is the code I was using for the test so that you can confirm on your end.

                    Code:
                    if(BarsInProgress == 0)
                    {
                         if (Historical)
                    	{
                    		Print("This will print historically");				
                    	}
                    		else if(!Historical)
                    	{
                    		Print("This will print during Live data");
                    	}
                    }
                    This is a known limitation when adding multiple data series, this is being looked into for future versions of NinjaTrader.

                    Please let me know if I may be of additional assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rtwave, Today, 01:49 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post rtwave
                    by rtwave
                     
                    Started by papaoutai, Today, 08:56 AM
                    0 responses
                    22 views
                    0 likes
                    Last Post papaoutai  
                    Started by jdspwe, Today, 05:22 AM
                    0 responses
                    13 views
                    0 likes
                    Last Post jdspwe
                    by jdspwe
                     
                    Started by JeremuFemstu, Today, 04:49 AM
                    0 responses
                    16 views
                    0 likes
                    Last Post JeremuFemstu  
                    Started by pjsmith, Today, 04:11 AM
                    1 response
                    22 views
                    0 likes
                    Last Post Green Lobster CBD  
                    Working...
                    X