Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multiple trading strategies

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

    multiple trading strategies

    Hello Ninjatrader Team,
    I have multiple trading system strategies that I have created (I have about 30 systems). What I am trying to do is whenever 3 or more of the 30 trading systems fire a long on the same candle then Ninjatrader should take a long position. What I want to clarify is. It could be anyone of the 30 trading systems, as long as it has 3 or more systems that agree on that one candle to go long. So for example let’s say on 1:25PM system 3, 15, 29 all agree to go long then take a long. Then short time later let’s say 2:25PM system 7,18,21,22,24 all agree to go long then take a long position. Please help me achieve this goal. Thank you

    P.S. I consider myself a beginner in coding please try to be specific on how to achieve this with Ninjatrader. I don’t want to waste your time. Thank you

    #2
    Hello wallstreetking,

    Thank you for your post.

    It is not possible to pull signals from one or more strategies into another. You can however pull signals from multiple indicators into a strategy. So in this case you would need to convert the strategies to indicators or one indicator and then call that indicator in your strategy or place the code in your strategy.

    We have Premium Paid Educational events where you will join a NinjaScript expert for a pair of 6-8 hour long intensive courses designed to provide you with an in depth look at programming indicators and automated strategies through the use of NinjaScript:



    If you would like to take on learning NinjaScript on your own, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.

    A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

    You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there.

    If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
    Click here for a list of certified NinjaScript Consultants

    Comment


      #3
      Hi wallstreetking,

      As PatrickH said, it's best to put all 30 strategies into one program. I'm assuming that you want to buy if the stock has qualified for any 3 strategies at any point during the candle, but not necessarily at exactly the same time.

      Create a DateTime variables, barProcessedTime, initialized to DateTime.MinValue. Create 30 integer strategy variables, all set to 0.

      First, compare barProcessedTime to Time[0], which is the opening time of this candle. If barProcessedTime is not equal to Time[0], then this is the first time processing this bar; reset all your 30 variables to 0. At the bottom of your logic, issue the statement "barProcessedTime = Time[0]".

      In the middle is the meat of your logic. If strategy 1 is true, set its variable to 1. After you've evaluated all 30 variables, add them together. If the total is greater than 3, then at least 3 strategies have qualified during this bar and you can buy the stock.

      Hope this helps.

      Comment


        #4
        Hey Egan, I want ninjatrader to take a long only when 3 or more of my strategies on the same bar fire a long. Here is a picture of what i mean.
        Attached Files

        Comment


          #5
          So after I convert all strategies into one indicators, how do i tell ninjatrader to fire a long when 3 or more indicators agree on the same bar??? what is the code i put in

          Comment


            #6
            Hi wallstreetking,

            if ((strat1 + strat2 + strat3 ....) >= 3)
            {
            EnterLong();
            }

            Comment


              #7
              Hello wallstreetking,

              Thank you for your response.

              Expanding on what egan857 provided here, you would need to check the values that produce the signals on the chart. In egan857's example we see that each indicator has been assigned a value, likely an int either representing 1 or 0 respectfully for when the signal is generated or not.

              Please let me know if I may be of further assistance.

              Comment


                #8
                thanks guys I made it work I really appreciated your guys help

                Comment


                  #9
                  Hey Ninjatrader Team,

                  I want to optimize my strategy, however i don't know how to do it when you open the script.. what I want to be able to do is optimize the >=3 see in the code


                  Code:
                  if ((strat1 + strat2 + strat3 ....) [B][U][COLOR="Blue"]>= 3[/COLOR][/U][/B])
                  {
                  EnterLong();
                  }
                  How can i tell ninja trade to optimize the >=3 from [1 to 28] in increments of 1

                  Comment


                    #10
                    Hello wallsteetking,

                    Thank you for your post.

                    You would need to make the 3 a public int. So the code would reflect the following:
                    Code:
                    #region Variables		
                            private int myInt = 3;
                            #endregion
                    protected override void OnBarUpdate()
                    {
                    if ((strat1 + strat2 + strat3 ....) >= myInt)
                    {
                    EnterLong();
                    }
                    }
                    		#region Properties
                    		/// <summary>
                    		/// </summary>
                    		[Description("")]
                    		[GridCategory("Parameters")]
                    		public int MyInt
                    		{
                    			get { return myInt; }
                    			set { myInt = Math.Max(1, value); }
                    		}
                    		#endregion
                    Only user defined variables can be optimized. For information on user defined variables please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=5782

                    Please let me know if I may be of further assistance.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by lorem, Yesterday, 09:18 AM
                    3 responses
                    13 views
                    0 likes
                    Last Post lorem
                    by lorem
                     
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    12 responses
                    42 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by FrazMann, Today, 11:21 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post FrazMann  
                    Started by geddyisodin, Yesterday, 05:20 AM
                    8 responses
                    52 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by DayTradingDEMON, Today, 09:28 AM
                    4 responses
                    27 views
                    0 likes
                    Last Post DayTradingDEMON  
                    Working...
                    X