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

Variable does not calculate

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

    Variable does not calculate


    MinStopFESX = PriorDayOHLC(Closes[19]).PriorClose[0]*0.01;

    This variable prints correctly on strategy A and not on strategy B

    Strategy B prints PriorDayOHLC(Closes[19]).PriorClose[0]*0.01 correctly as strategy A so it is picking up the data, but the variable MinStopFESX prints 0 in strategy B....... ideas?

    In both strategies the variable is a double.

    #2
    Hello elliot5,

    Thank you for your post.

    Please check the 'Days to load' property for the Data Series you applied the strategies to. Are the 'Days to load' settings the same?

    Do your strategies add a secondary series using AddDataSeries()?

    After checking the 'Days to load' settings, add a print to your strategies that print out the Time[0] of the bar and also the PriorClose (PriorDayOHLC().PriorClose[0]). Then, save the output of each strategy to text files and post them here so we may further investigate.

    To save the output, right-click the Output window and select Save As... > give the output file a name and save > then attach the output from both strategies to your reply.

    Below is a link to a forum post that demonstrates using prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Days to load is same value for both strategies.
      Yes the strategies have a large array of AddDataSeries. Both print the value as stated above and both have the same size of array. The file contains mixed prints from both strategies.. marked of course. now I shall attach the print of the variable that = (PriorDayOHLC(Closes[19]).PriorClose[0].

      How on earth is that possible?
      Attached Files
      Last edited by elliot5; 05-11-2021, 09:38 AM.

      Comment


        #4
        Hello elliot5,

        Thank you for that information.

        It seems that both strategies are printing to the same Output window at the same time making it difficult to determine which print comes from each strategy. Also, we are expecting more than one day of prints since you are using a BarsInProgress of 19 (PriorDayOHLC(Closes[19]).PriorClose[0]). If there is no previous day of data, PriorClose will not have anything to calculate.

        Please isolate the code in question to separate test scripts and add the following Print statement below to each test script. Then, run one script at a time on more than one day of data and save the output of the script to a text file, ensuring to clear the Output window between testing each strategy. After saving the output for each reduced test strategy, please attach the output results of each strategy to your reply.

        Print(string.Format("{0} | BarsInProgress: {1}, CurrentBar: {2}, Closes[19][0]: {3}, PriorDayOHLC(Closes[19]).PriorClose[0]: {4}", Time[0], BarsInProgress, CurrentBar, Closes[19][0], PriorDayOHLC(Closes[19]).PriorClose[0]));

        I look forward to assisting further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Look more carefully. Both prints are labelled as being the error or error-free strategy. Please find attached the requested prints.
          Attached Files
          Last edited by elliot5; 05-11-2021, 10:43 AM.

          Comment


            #6
            Hello elliot5,

            Thank you for that information.

            After reviewing the output of your strategies, we are not seeing a print occur for BarsInProgress 19 in either strategy's output. We also do not see that BarsInProgress 19 has data for the previous day in either strategy. If BarsInProgress 19 does not have data then a print for BarsInProgress 19 would not occur in the output. To print out information about the PriorClose for BarsInProgress 19, you would need to ensure that you have data for that added series.

            Also note, you would only need to add the debugging print in my previous post for BarsInProgress 19 to see it's output. You would not need to add prints for the other added series. To add the debugging print for only BarsInProgress 19, you could create a condition that checks if (BarsInProgress == 19) and calls the print previously mentioned.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              In the initial files I sent you the value of the previous day was being printed for [19]. Both strategies print the (PriorDayOHLC().PriorClose[0]) but one does not print the variable that = it. This variable has been corrected printed by both strategies for months until Monday this week.

              Comment


                #8
                Hello elliot5,

                Thank you for your note.

                Please modify the debugging print in both test scripts so that it prints out information about only BarsInProgress 19. Then, test both scripts one at a time, save the output to a txt file, and report your results.

                To add the debugging print for only BarsInProgress 19, you could create a condition that checks if (BarsInProgress == 19) and calls the print. This would check if BarsInProgress 19 is the series processing and print information about it to the output window. Then, we could compare the print values for BarsInProgress 19 between both scripts.

                I look forward to further assisting.

                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  As you will see both strategies print the same output using the string below. The variable that = PriorDayOHLC(Closes[19]).PriorClose[0] prints 0 for one strategy and the correct figure for the other. Very very strange behaviour that has been costly. For real money traders reliability is king.

                  if (BarsInProgress == 19)
                  Print(string.Format("{0} | BarsInProgress: {1}, CurrentBar: {2}, Closes[19][0]: {3}, PriorDayOHLC(Closes[19]).PriorClose[0]: {4}", Time[0], BarsInProgress, CurrentBar, Closes[19][0], PriorDayOHLC(Closes[19]).PriorClose[0]));
                  Attached Files
                  Last edited by elliot5; 05-12-2021, 01:26 AM.

                  Comment


                    #10
                    I attach the prints with both the variable and the formula for it. The correct strategy calculates and prints the variable correctly after about 1 second. The error strategy never calculates the variable.
                    Attached Files

                    Comment


                      #11
                      Hello elliot5,

                      Thank you for that information.

                      In the first set of outputs containing the print we advised adding to the strategy, PrintErrorVarialble and PrintCorrectVariable, we see that the output data is incomplete. We are only seeing data occur for a single bar (bar 62) and we are only seeing data for a single day. The goal of using the advised print is that we are trying to confirm that series 19 has processed a previous day of data.

                      Can you confirm that the print we advised to add is not inside of any conditions other than a condition to limit the prints to BarsInProgress 19.

                      Once the above is confirmed, please do the following.
                      • Open charts for the instrument that is used for BarsInProgress 19 and for the primary instrument that you are testing the strategy on. Ensure that more than 1 day of data is loaded on the chart.
                      • Right-click on the charts, select 'Reload historical data', and confirm that all the data is there for the BarsInProgress 19 instrument and the primary instrument the strategy is tested on.
                      • Once the data is confirmed to be there, please retest the reduced strategies one at a time with the prints we provided included in the strategies. I am reattaching the prints below. Do you see similar values printing for both strategies when comparing their output?
                      • Save the output of each strategy to a text file and report results.
                      Print(string.Format("{0} | BarsInProgress: {1}, CurrentBar: {2}, Closes[19][0]: {3}, PriorDayOHLC(Closes[19]).PriorClose[0]: {4}", Time[0], BarsInProgress, CurrentBar, Closes[19][0], PriorDayOHLC(Closes[19]).PriorClose[0]));

                      If you are stuck testing the reduced strategies, please send us the reduced strategies with the above print included in it, the settings you are using, and the steps you are taking to test the strategies so that we may test them on our end to further investigate.

                      I look forward to assisting further.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        The following prints should help. Also see the last two prints - you will see that the error strategy does not print out a large number of variables for other contracts too. This is a real problem because these variables matter for large account risk management.
                        Attached Files
                        Last edited by elliot5; 05-13-2021, 02:31 AM.

                        Comment


                          #13
                          Hello elliot5,

                          Thank you for your note.

                          With NinjaScript related items, we find that working through email/forums is best for our NinjaScript Support. This gives our Support team time to research and test your inquiry to ensure we have the best information available for you.

                          Our calls are kept to approximately 20 minutes and we find that calls for NinjaScript can easily surpass our allotted time for a call, as NinjaScript questions can be complex.

                          That said, please send us the reduced copies of the strategies as well as the steps to reproduce the behavior so we may investigate further on our end. Note that a reduced strategy means that the strategy only includes the code that demonstrates the issue and all other code is commented out or removed.

                          After testing the reduced strategies and investigating further on our end, we will reach out to you to arrange a remote support call.

                          I look forward to further assisting.
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            Worked all night on it - removed the strategy assemblies and reinstated them in Editor. Solved the problem - no idea how. Will report if this issue turns up again. Thank you BrandonH
                            Last edited by elliot5; 05-13-2021, 03:41 AM.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by algospoke, 04-17-2024, 06:40 PM
                            6 responses
                            48 views
                            0 likes
                            Last Post algospoke  
                            Started by arvidvanstaey, Today, 02:19 PM
                            4 responses
                            11 views
                            0 likes
                            Last Post arvidvanstaey  
                            Started by samish18, 04-17-2024, 08:57 AM
                            16 responses
                            61 views
                            0 likes
                            Last Post samish18  
                            Started by jordanq2, Today, 03:10 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post jordanq2  
                            Started by traderqz, Today, 12:06 AM
                            10 responses
                            19 views
                            0 likes
                            Last Post traderqz  
                            Working...
                            X