• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 sgordet, Yesterday, 10:31 PM
                0 responses
                1 view
                0 likes
                Last Post sgordet
                by sgordet
                 
                Started by Ilpropio, Yesterday, 09:45 PM
                0 responses
                4 views
                0 likes
                Last Post Ilpropio  
                Started by Revan, Yesterday, 05:44 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Marco  
                Started by superg3, Yesterday, 07:57 PM
                0 responses
                4 views
                0 likes
                Last Post superg3
                by superg3
                 
                Started by Longhornmark, Yesterday, 07:06 AM
                5 responses
                36 views
                0 likes
                Last Post nkhoi
                by nkhoi
                 
                Working...
                X