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 DJ888, Today, 10:57 PM
                0 responses
                6 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by MacDad, 02-25-2024, 11:48 PM
                7 responses
                158 views
                0 likes
                Last Post loganjarosz123  
                Started by Belfortbucks, Today, 09:29 PM
                0 responses
                7 views
                0 likes
                Last Post Belfortbucks  
                Started by zstheorist, Today, 07:52 PM
                0 responses
                7 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                151 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Working...
                X