Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Same Strategy in different Charts

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

    Same Strategy in different Charts

    I'm not new to programming, but new to programming in NT. Each instance of a strategy has it's own qualifier, so this is a little strange.

    I have a stategy with the following:


    public class VTTester : Strategy
    {
    #region Variables
    #endregion
    public System.Collections.ArrayList symbols = new System.Collections.ArrayList();
    public System.Collections.ArrayList list = new System.Collections.ArrayList();
    ....
    }

    When I run this on different charts and access the symbol(there is only one actually in the list), the first instance sees the symbol from the last instance in the first instance. This should not be happening, so maybe you all have some information for me to help me out.

    Thanks,

    Leroy

    #2
    ldissinger, NinjaTrader strategies are designed to operate completely independent of each other. Is there a specific reason you have the symbols and list objects public? If not, setting them to private should limit the cross-communication.
    AustinNinjaTrader Customer Service

    Comment


      #3
      I tried making the member variables private, but no luck. Do ALL of the strategies have to be unloaded for this to take effect? I know that .NET is good at keeping assemblies loaded.

      Leroy

      Comment


        #4
        Leroy, there could definitely be some memory issues going on here. Please try removing all of the strategies from the strategy tab and then restart your computer and see if the issue persists.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thank you for the quick responses. My strategy is a pseudo real time strategy based on some other software. I will have to wait until Monday to verify if this works.

          From a programming standpoint....public member variables should only be available to the specific instance which created it. So public vs. private should not make a difference.

          On another note, I was going to create a multiple instrument strategy, but had so many problems accessing the data (sometimes I'd get zero or the wrong information from the request) that I changed it to a single instrument to make it simpler on NT.

          My background is real time programming in assembly, C, C++. Was a .NET architect for a huge company, so I don't think I am a total moron. I've done all kinds of theading and such and never had these kinds of issues before, so maybe it is me....maybe not.

          I'll let you know how it goes on Monday.

          Thanks again,

          Leroy

          Comment


            #6
            Sounds good, Leroy. I'll have a coworker take a look at this thread too and see if he has anything to add.
            AustinNinjaTrader Customer Service

            Comment


              #7
              StateMachine with static member

              It just dawned on me

              I have an object oriented state machine where this is a base class and all derived objects are of type StateMachine.

              In the Base object StateMachine, I have a static variable called VTTester which is a reference to the Strategy....VTTester.

              Because NT is a single program, this static variable is global to all instances of state machine even across charts...because it is running under a single instance of Ninja Ttrader (NT). So, when I bring up a new chart, this global gets set on start up and then it is applying to ALL instances of my strategies and state machines.

              So, the lessoned learned it not to use statics in NT if you want multiple charts to run a single strategy.

              Leroy
              Last edited by ldissinger; 06-25-2011, 01:18 PM. Reason: clarification

              Comment


                #8
                Leroy, thanks for this informative update. I'm sure others will find what you've discovered here helpful.
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Austin View Post
                  ldissinger, NinjaTrader strategies are designed to operate completely independent of each other. Is there a specific reason you have the symbols and list objects public? If not, setting them to private should limit the cross-communication.
                  Austin,

                  I want to trade 300 symbols through autotrading. I have written 3 strategies that need to be applied across these 300 symbols. Currently it seems I need to open 300 charts. Is there other ways to do it. Please let me know.

                  Thx
                  Nagendra

                  Comment


                    #10
                    Nagendra, you can add all 300 symbols to an instrument list, and then right-click the strategies tab -> add a strategy -> add the strategy to the instrument list. That way you don't even have to open a single chart.
                    AustinNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Austin,

                      Thats great!!. This is really great capability. NT will be my dream tool with this.

                      Thx
                      Nagendra

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Javierw.ok  
                      Started by timmbbo, Today, 08:59 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post bltdavid  
                      Started by alifarahani, Today, 09:40 AM
                      6 responses
                      40 views
                      0 likes
                      Last Post alifarahani  
                      Started by Waxavi, Today, 02:10 AM
                      1 response
                      19 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Working...
                      X