Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

submit orders from a custom class methods

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

    submit orders from a custom class methods

    how can i call EnterLong() from a custom class method?

    i basically want to code a button that enters into a position when i click it using the Click even.

    #2
    Hello savekad,

    Custom classes are something that we cannot support, but with that said you may view the following strategy that creates a Long and Short button button that you may use as a reference.



    To Import
    1. Download the file to your desktop
    2. From the Control Center window select the menu File > Utilities > Import NinjaScript
    3. Select the downloaded file
    JCNinjaTrader Customer Service

    Comment


      #3
      thanks for the idea but i need a new form that is now already a live object like the tool strip so i use a separate class for it.

      can you please reference me to a sample, any sample, that uses ninja methods from an external class object?

      Comment


        #4
        Hello savekad,
        Unfortunatley we do not have a sample code in these lines however you can try something like below

        Code:
        private class InnerClass
        {
        	Strategy s;
        	public InnerClass(Strategy s)
        	{
        		this.s = s;
        	}
        	
        	public void GoLong()
        	{
        		s.EnterLong();
        	}
        	
        }
        and you can call the class from your strategy as
        Code:
        InnerClass ic = new InnerClass(this);
        ic.GoLong();
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Joydeep View Post
          Hello savekad,
          Unfortunatley we do not have a sample code in these lines however you can try something like below

          Code:
          private class InnerClass
          {
              Strategy s;
              public InnerClass(Strategy s)
              {
                  this.s = s;
              }
              
              public void GoLong()
              {
                  s.EnterLong(); [COLOR=Red][B]// unknown to InnerClass[/B][/COLOR]
              }
              
          }
          and you can call the class from your strategy as
          Code:
          InnerClass ic = new InnerClass(this);
          ic.GoLong();
          the thing is that EnterLong() is an unknown method to my custom class...

          Comment


            #6
            Hello savekad,
            Please make sure you have added proper references if you have appended the class in a separate file.
            Code:
            import NinjaTrader.Strategy;
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              is 'import' part of C#? i never ran into it.

              if you meant 'using' then it shouldn't be necessary because the custom class is on the same cs file as the strategy.

              any other idea?

              Comment


                #8
                Hello savekad,
                My apologies. Yes, it will be using and not import.

                I have attached a sample code which further demonstrates the scenario.
                Attached Files
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                649 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                576 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X