• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error in Bars.GetBar()

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

    Error in Bars.GetBar()

    Hi
    I have a ninja7 strategy and want to convert it to 8.
    It calculates the max and min value between a special period. it uses GetBar to do that and i converted it to this piece of code :

    localZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
    startDate = TimeZoneInfo.ConvertTimeFromUtc(startDate, localZone);
    endDate = TimeZoneInfo.ConvertTimeFromUtc(endDate, localZone);


    startBarsAgo = Bars.GetBar(startDate);
    endBarsAgo = Bars.GetBar(endDate);


    nightSessionHigh = MAX(High, startBarsAgo - endBarsAgo + 1)[endBarsAgo];
    nightSessionLow = MIN(Low, startBarsAgo - endBarsAgo + 1)[endBarsAgo];


    it calculates two important values : startBarsAgo and startBarsAgo according to the time zone of PC. the it runs Bars.GetBar(startDate) and here i catch an exepction:

    Value of property 'Period' of NinjaScript 'MAX' is -43692 and not in valid range between 1 and 2147483647.

    The values of fields are
    startBarsAgo : 618791
    endBarsAgo : 662484

    So what should i do?

    #2
    Hello amiralimadadi,
    Thanks for your post.

    I have seen this before, but I can't find the post right now. What I would do is Print() each line in NT7 and NT8 to the NS Output window and compare the values. This will help us figure out where exactly the issue is.

    Let me know where you find the difference and we can go from there.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      I have done it before and this is the line where the error exactly occurred:


      startBarsAgo = Bars.GetBar(startDate);

      Comment


        #4
        What was the NT7 code for that line?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          That's a simple question:
          How to get max and min values of bars during a special time?
          for example: from 8/22/2018 8AM to 8/23/2018 2PM. The distance is too big and NT8 says that :

          Value of property 'Period' of NinjaScript 'MAX' is -43692 and not in valid range between 1 and 2147483647.

          Comment


            #6
            Looking at the help guide it looks like you may need to do something like this instead:
            Code:
            startBarsAgo = CurrentBar - Bars.GetBar(startDate);
            Help Guide GetBar()
            Josh G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by safbrathpro, Today, 05:51 AM
            0 responses
            4 views
            0 likes
            Last Post safbrathpro  
            Started by abfefmu, Today, 05:33 AM
            0 responses
            4 views
            0 likes
            Last Post abfefmu
            by abfefmu
             
            Started by bbdjad, Today, 04:36 AM
            0 responses
            4 views
            0 likes
            Last Post bbdjad
            by bbdjad
             
            Started by mittie3, Today, 03:33 AM
            0 responses
            7 views
            0 likes
            Last Post mittie3
            by mittie3
             
            Started by Againmain1, Today, 03:04 AM
            0 responses
            8 views
            0 likes
            Last Post Againmain1  
            Working...
            X