Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Jonafare, 12-06-2012, 03:48 PM
              5 responses
              3,985 views
              0 likes
              Last Post rene69851  
              Started by Fitspressorest, Today, 01:38 PM
              0 responses
              2 views
              0 likes
              Last Post Fitspressorest  
              Started by Jonker, Today, 01:19 PM
              0 responses
              2 views
              0 likes
              Last Post Jonker
              by Jonker
               
              Started by futtrader, Today, 01:16 PM
              0 responses
              7 views
              0 likes
              Last Post futtrader  
              Started by Segwin, 05-07-2018, 02:15 PM
              14 responses
              1,792 views
              0 likes
              Last Post aligator  
              Working...
              X