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

string text question

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

    #16
    Originally posted by NinjaTrader_PatrickH View Post
    Hello duck_CA,

    Thank you for your post.

    Attached is the full script that works on my end.

    Please let me know if you have any questions.
    thank you so much! looks great!

    think i see why the prior code didn't work

    Code:
    private Days day = Day.Monday;
    new

    Code:
    private Day day = Day.Monday;

    and

    Code:
     [Description("")]
            [GridCategory("Parameters")]
            public Days Day
            {
                get { return day; }
                set { day = value; }
            }
    new

    Code:
     [Description("")]
            [GridCategory("Parameters")]
            public Day Day
            {
                get { return day; }
                set { day = value; }
            }

    Comment


      #17
      can you tell me if the indicator you provided is v8 compliant?

      thanks!

      Comment


        #18
        Hello duck_CA,
        NinjaTrader 7 scripts will need to be re-coded for NinjaTrader 8: http://ninjatrader.com/support/helpG...ng_changes.htm
        BrandonNinjaTrader Customer Service

        Comment


          #19
          Hi Patrick,

          can you tell me why the following code will not compile correctly?
          which = (i==1) ? lvnBrush : hvnBrush : svnBrush ;
          the original code below works fine but i'm trying to add one more
          which = (i==1) ? lvnBrush : hvnBrush ;
          thanks,

          I added the svnBrush to all other areas in editor without errors

          Comment


            #20
            That's because the ?: operator only supports two results based of a true of false condition.

            Learn about the C# ternary conditional operator, (`?:`), that returns the result of one of the two expressions based on a Boolean expression's result.


            You would need to add a secondary condition to the last result of the first ?: operator

            Example-
            Code:
            which = (i==1) ? lvnBrush : (i==2 ? hvnBrush : svnBrush );

            Comment


              #21
              Hello duck_CA,

              Calonious is correct on how to handle this.

              Comment


                #22
                thank you!!!

                Originally posted by Calonious View Post
                That's because the ?: operator only supports two results based of a true of false condition.

                Learn about the C# ternary conditional operator, (`?:`), that returns the result of one of the two expressions based on a Boolean expression's result.


                You would need to add a secondary condition to the last result of the first ?: operator

                Example-
                Code:
                which = (i==1) ? lvnBrush : (i==2 ? hvnBrush : svnBrush );

                Comment


                  #23
                  Another option is use to a switch case if you start getting more scenarios you need to test for
                  Example
                  Code:
                  switch(i)
                  {
                      case 1:
                            which = lvnBrush;
                            break;
                      case 2:
                            which = hvnBrush;
                            break;
                      default:
                            which = svnBrush ;
                            break;
                  }

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by arvidvanstaey, Today, 02:19 PM
                  4 responses
                  10 views
                  0 likes
                  Last Post arvidvanstaey  
                  Started by samish18, 04-17-2024, 08:57 AM
                  16 responses
                  56 views
                  0 likes
                  Last Post samish18  
                  Started by jordanq2, Today, 03:10 PM
                  2 responses
                  8 views
                  0 likes
                  Last Post jordanq2  
                  Started by traderqz, Today, 12:06 AM
                  10 responses
                  18 views
                  0 likes
                  Last Post traderqz  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  5 responses
                  47 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X