Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need to code - Ninjatrader

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

    #16
    Hi,
    Is there any function which lets me account for connection problems.
    eg. when connection is suddenly terminated, do something.

    Comment


      #17
      nemesis45, the print could be expected as the Initialize() is called across all scripts of the same category (indicator / strategy).

      You could monitor the OnConnectionStatus handler - http://www.ninjatrader.com/support/h...tionstatus.htm
      BertrandNinjaTrader Customer Service

      Comment


        #18
        Static variable!

        When i declare a variable in ninjascript, just inside my main class
        why doesnt it have to be static to be used?!

        took me a couple of days to debug this, but i just want to know, if you declare a non static variable, how can ninjascript allow it to be used withing one of its functions?

        Comment


          #19
          Originally posted by nemesis45 View Post
          When i declare a variable in ninjascript, just inside my main class
          why doesnt it have to be static to be used?!

          took me a couple of days to debug this, but i just want to know, if you declare a non static variable, how can ninjascript allow it to be used withing one of its functions?
          Each instance of an object shares a static variable.

          A non static variable is only per each instance.

          And then depending on the scope, that determines where it can be seen within the instance.

          Comment


            #20
            Originally posted by sledge View Post
            Each instance of an object shares a static variable.

            A non static variable is only per each instance.

            And then depending on the scope, that determines where it can be seen within the instance.
            class NTstrategy : strategy
            {
            private int number =5;

            function()
            {
            number =10;
            }
            }

            vs
            private static int number =5;

            ninjatrader actually allows me to declare number as in example 1. it doesnt have to be static at all. same thing in c# returns an error.

            Why is it so? of course when i use a global variable as in this example, i should have to declare it as static in C# , i can code it otherwise in ninjascript. i just wanted to know why is it done this way in NT
            Last edited by nemesis45; 04-11-2014, 08:42 PM.

            Comment


              #21
              nemesis45, you likely tried accessing that non static from a static method in C# directly (as the Main method would be). So that's the difference here.
              BertrandNinjaTrader Customer Service

              Comment


                #22
                you are right, thanks a lot

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                26 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, Yesterday, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                191 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,230 views
                0 likes
                Last Post xiinteractive  
                Working...
                X