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 cre8able, Today, 03:20 PM
            0 responses
            5 views
            0 likes
            Last Post cre8able  
            Started by Fran888, 02-16-2024, 10:48 AM
            3 responses
            47 views
            0 likes
            Last Post Sam2515
            by Sam2515
             
            Started by martin70, 03-24-2023, 04:58 AM
            15 responses
            114 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by The_Sec, Today, 02:29 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by jeronymite, 04-12-2024, 04:26 PM
            2 responses
            31 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X