Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to choose either going long or short an instrument in Inputs so i can toggle

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

    How to choose either going long or short an instrument in Inputs so i can toggle

    I use COT report trading and only want to follow the big money using my indicator set parameters for each instrument.

    Ex. How would i create an input condition set that would allow me to only look for longs in an instrument?

    and vice versa with instruments im looking to go short in? How do i toggle an input to look for one direction instead of bilateral movements?

    #2
    Hello cameo86,

    You may create a user defined input so that you can check inside of your code for you entry conditions. For example:
    Code:
     #region Variables
            private bool onlyGoLong = true; // Default setting for OnlyGoLong
    #endregion
    
    protected override void OnBarUpdate()
    {
            if (OnlyGoLong == true && //Your Trade Condition)
            {
                  //Go Long
            }
            
            if( OnlyGoLong == false && //Your Trade Condition)
            {
                  //Go Short
             }
    }
    
    #region Properties
            [Description("Only take Long trades, if false only take Short trades")]
            [GridCategory("Parameters")]
            public bool OnlyGoLong
            {
                get { return onlyGoLong; }
                set { onlyGoLong = value; }
            }
    #endregion
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply

      Could i copy and paste this under my variables after i finish my strategy wizard and will it work, so i can finish this strategy this weekend?

      Do i also have to create an input on the wizard for this function to be a yes or no (as in go long or short toggle) or does this code fullfill the responsibility of me using the wizard in place of this variable code?

      Any help will be greatly appreciated

      Comment


        #4
        How would i do this in the strategy wizard

        Creating a User defined input called LongShort and then how do i do this in the strategy wizard? All i want is a toggle between going long or short based on my condition paremeters between my long and short set ups?

        I tried using strategy: long and using my input series of 'longshort' but i couldn't select them

        Comment


          #5
          For instance this is my code so far for going long

          // Condition set 1
          if (CrossAbove(MACD(12, 26, 9), MACD(12, 26, 9).Avg, 1)
          && CrossAbove(ADX(Close, 14), ADXStrength, 1)
          && CrossAbove(DM(14).DiPlus, DM(14).DiMinus, 1)
          && CrossAbove(Stochastics(7, 14, 3).K, Stochastics(7, 14, 3).D, 1))
          {
          EnterLong(1, "");


          Im sorry i just want to be able to toggle this, a yes, no 1,2 for either going long or short, how would i code it (preferably in the strategy wizard if i can)

          Comment


            #6
            Hello cameo86,

            If you are using the Strategy Wizard, you would define a User input in the "User Defined Inputs" section, then be able to use it inside of the Condition and Actions window. Attached is an example of this.

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

            Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.
            Attached Files
            JCNinjaTrader Customer Service

            Comment


              #7
              Thanks that helped me out a bunch!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              647 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              368 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X