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

Logical Comparisons of BarArray and Time values Question

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

    Logical Comparisons of BarArray and Time values Question

    I want to do some logical comparisions:

    one for secondary data and one for time.

    For secondary data I wanted to do the following:

    if BarsArray[2] > upBegin then...
    // perform an action

    Before I manually edited the script I used the wizard to create the upBegin valuable which is int a constant ...i.e.
    privateint upBegin = 1000; // Default setting for UpBegin

    and also has the wizard created properties in the property section of the code.

    The BarsArray[2] data is meant to be market statistically data so seems to be integer values and I believe I have defined that correctly.

    When ever I try to do this I get CS0019 error code - not sure what I need to do to do this type of logical comparison. Is there some sort of typing I need to do?

    For a time comparison I ran into a similar error condition when doing the following:

    if (Time[0].DayOfWeek == dayOfWeek)return;

    where dayofWeek is
    privateint dayOfWeek = 5; // Default setting for DayOfWeek


    Any insight is appreciated....thanks so much

    #2
    Hello Kel108,
    If you evaluate your code as stated below then can you compile your code correctly.

    Code:
    if ((int)Time[0].DayOfWeek == dayOfWeek)return;
    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks Joydeep - much appreciated - that worked nicely...however when I tried the same thing with

      if (BarsArray[2] > upBegin)
      // perform an action

      I got a message that I could not perform a type conversion for ninja data. So is there a way I can make UpBegin the same datatype for easy comparison?

      Thanks in advance.

      Ed

      Comment


        #4
        Hello Ed,
        Are you trying to compare the data with the close of the 2nd secondary series? If so then please use the below code
        Code:
        if (Closes[2][0] > upBegin)
        {
           //do something
        }
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Yes I was thank you so much - eventually I will get the hang of all this...but sometimes I learn in a painfully slow manor

          Comment


            #6
            Hello Ed,
            Thanks for your note.

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kempotrader, Today, 08:56 AM
            0 responses
            6 views
            0 likes
            Last Post kempotrader  
            Started by kempotrader, Today, 08:54 AM
            0 responses
            4 views
            0 likes
            Last Post kempotrader  
            Started by mmenigma, Today, 08:54 AM
            0 responses
            2 views
            0 likes
            Last Post mmenigma  
            Started by halgo_boulder, Today, 08:44 AM
            0 responses
            1 view
            0 likes
            Last Post halgo_boulder  
            Started by drewski1980, Today, 08:24 AM
            0 responses
            4 views
            0 likes
            Last Post drewski1980  
            Working...
            X