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

Testing the "Load data based on" property in the DataSeries

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

    Testing the "Load data based on" property in the DataSeries

    Hello:

    I'm asking this question on the Forum as directed by NT TS as this is one of those undocumented/unsupported items that they understandably avoid.

    There are 3 possible choices for the "Load data based on" property in the DataSeries panel; Days, Bars, CustomRange.

    The code:
    Print("Type: " + Bars.BarsData.RangeType ");

    returns
    Type: Days (or whatever it is set to) which is correct according to the setting.

    and appears that it is a string. There are no blanks on either side of the response.

    It seems like a simple string comparison (String.Equals or String.Compare) could be used to compare the response to a string variable. I have not been able to find the correct string compare method or syntax to get the test to work;

    I need to be able to test if it is set to "Days" and if not do something different.

    I've tried countless variations but have yet to find the correct one. They compile fine but the return has always been a false condition. I've been using the simplist method which compares 2 strings and returns a Boolean result.

    Has anyone tried this before and gotten it to work and either is willing to share or work up the code?

    With appreciation:

    Frank

    #2
    Hello Frank,

    Thank you for your note.

    When I put the following in an indicator and apply it to a daily chart it correctly prints,

    Code:
    if(Bars.BarsData.RangeType.ToString()=="Days")
    	Print("Its a daily");
    Does this work for you?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan:

      Worked perfectly.

      As one of the TS people pointed out in an email to me prior to your post, the Type is an enum which because it is in a drop down I probably should have been able to figure out if I thought about it enough(lesson learned).

      I know how to test for a specific enum in a case statement but not in an if statement, which is probably doable. I tried replacing what would be the "case" statement syntax with an "if" but that didn't compile. I didn't work too hard finding out how to do it seeing that you have given me a workable solution.

      It would be nice to know to test the value of an enum using an ":if".

      Anyway, thank you for your assistance.
      Last edited by Cheech; 08-02-2018, 11:27 AM.

      Comment


        #4
        Hello Cheech,

        I've attached a NT8 sample which does this.

        See line 716.

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Gerik, Today, 09:40 AM
        2 responses
        6 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by RookieTrader, Today, 09:37 AM
        2 responses
        10 views
        0 likes
        Last Post RookieTrader  
        Started by alifarahani, Today, 09:40 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by KennyK, 05-29-2017, 02:02 AM
        3 responses
        1,285 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by AttiM, 02-14-2024, 05:20 PM
        11 responses
        186 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X