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 algospoke, Yesterday, 06:40 PM
                2 responses
                19 views
                0 likes
                Last Post algospoke  
                Started by ghoul, Today, 06:02 PM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                45 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                20 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                181 views
                0 likes
                Last Post jeronymite  
                Working...
                X