Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order generation from strategy for manual trading

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

    Order generation from strategy for manual trading

    Hi -
    I have a strategy that I would like to run end of day on a watchlist and manually trade the generated signals the following day. The strategy is not real time and works off daily charts. Any suggestions on how I can do this in Ninjatrader?

    Other option I tried is to add following OnOrderUpdate() method to the strategy and run it through strategy analyzer. But the problem with the code is it prints all the historical orders whereas I need only the last pending submit order AND is not filled.

    Code:
    protected override void OnOrderUpdate(IOrder order)
    {
    	if (order.OrderState == OrderState.PendingSubmit)
    	{
    		orderStr = order.ToString();
    		Print(orderStr);
    	}			
    }
    Regards

    #2
    Correct the Strategy Analyzer would not help here atrader123. For daily monitoring it might be better to the signals given into an indicator that you can then run off the Market Analyzer window on your custom watchlist of instruments.

    Comment


      #3
      Hi Bertrand,
      I thought market analyzer is only for real time data. Just to make sure I understand the steps, can you comment/correct following workflow?

      For each strategy,
      (a) Create a custom indicator that returns digit code for each type of order (entry, exit, stop..)
      (b) Add this indicator as one of the columns in Market Analyzer
      (c) Each day run market analyzer on watchlist and add this custom indicator as one of the columns to see which markets have new entry, exit, trail stop signals.

      I am not fully familiar with market analyzer. Along with signal code string, Is it possible to display the signal values like price to enter/exit/set new stop value etc in market analyzer column?

      I have also a multi-instrument rotational strategy. I am assuming, one can do the same as above for this type of strategy as well i.e., have the base instrument in market analyzer but in the indicator column display the list of secondary instruments to buy/sell and the values?

      Regards

      Comment


        #4
        Hello atrader123,

        You can look and calculate on previous days data.

        Yes, when you add an indicator to the Market Analyzer it will show you the value of the plot instead of plotting it on a chart.
        http://www.ninjatrader.com/support/h...th_columns.htm

        I have also a multi-instrument rotational strategy. I am assuming, one can do the same as above for this type of strategy as well i.e., have the base instrument in market analyzer but in the indicator column display the list of secondary instruments to buy/sell and the values?
        Yes that would be correct.
        JCNinjaTrader Customer Service

        Comment


          #5
          I notice that if one applies a strategy to an instrument and enable it, the order tab shows the latest working orders. This might help in sidestepping the need to create indicators for each of my strategies for each type of signal/order. If a watchlist is large, it is not practical to enable strategy manually for each instrument though.

          How can I set a strategy (via configuration or via code) to have enable=true as default when it is applied to a watch list through Strategies tab?

          Comment


            #6
            Hello atrader123,
            Please follow the below steps to enable all the strategies at once from the strategies tab:
            • In the Strategies tab select on any strategy
            • Press CTRL + A to select all the strategies
            • Right click on the data grid
            • In the context menu click on Enable
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Thanks. I will check it out.

              Comment


                #8
                I spent last few days trying to make this basic scenario work without success.

                The scenario is same as what was mentioned earlier i.e., (a) End of each day, I would like to run an automated strategy on a watchlist, (b) NT spits out list of buy/sell/stop orders and (c) I place orders manually next day with different brokers accordingly.

                I would appreciate if someone can point/show me how to do above use case step-by-step. I could not find any NT documents that takes a user step-by-step on how to do this using NT from beginning to end. I have been already through various NT documentation and also have seen couple threads in the forum with questions on this same use case. I could not figure out if/how the users are finally able to solve.

                Following is a sample program to generate the buy and sell orders. Currently it is programmed to trigger a buy order if current bar is Friday. So I expected a buy order to be there in the orders tab.

                I tried all three options i.e., running via strategy analyzer, via chart and via strategies tab. Also with ExitOnClose to false. I should be getting a buy order for this last Friday. I don't see that. The program does generate orders and works fine for prior weeks. Please let me know if you need any additional information.

                Code:
                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Diagnostics;
                using System.Drawing;
                using System.Drawing.Drawing2D;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Data;
                using NinjaTrader.Indicator;
                using NinjaTrader.Gui.Chart;
                using NinjaTrader.Strategy;
                #endregion
                
                // This namespace holds all strategies and is required. Do not change it.
                namespace NinjaTrader.Strategy
                {
                    /// <summary>
                    /// Enter the description of your strategy here
                    /// </summary>
                    [Description("Enter the description of your strategy here")]
                    public class SampleOrderTest : Strategy
                    {
                        protected override void Initialize()
                        {			
                            CalculateOnBarClose = true;
                        }
                		
                		protected override void OnBarUpdate()
                        {
                			DayOfWeek week_day = Time[0].DayOfWeek;
                			
                			DayOfWeek buyDay = DayOfWeek.Friday;
                			DayOfWeek sellDay = DayOfWeek.Monday;
                			
                			if(week_day == buyDay)
                			{
                				EnterLong(DefaultQuantity, "");
                			}
                			if(week_day == sellDay)
                			{
                				ExitLong("");
                			}
                        }
                    }
                }

                Comment


                  #9
                  Hello atrader123,

                  So you would like to run a NinjaScript on a list of Instruments to give you the prices on where to place your Buy/Sell/Stop orders manually inside of NinjaTrader, or did you want to run a NinjaScript to place the orders place the Buy/Sell/Stop orders for you on a list of instruments?
                  JCNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by atrader123 View Post
                    I spent last few days trying to make this basic scenario work without success.

                    The scenario is same as what was mentioned earlier i.e., (a) End of each day, I would like to run an automated strategy on a watchlist, (b) NT spits out list of buy/sell/stop orders and (c) I place orders manually next day with different brokers accordingly.

                    I would appreciate if someone can point/show me how to do above use case step-by-step. I could not find any NT documents that takes a user step-by-step on how to do this using NT from beginning to end. I have been already through various NT documentation and also have seen couple threads in the forum with questions on this same use case. I could not figure out if/how the users are finally able to solve.

                    Following is a sample program to generate the buy and sell orders. Currently it is programmed to trigger a buy order if current bar is Friday. So I expected a buy order to be there in the orders tab.

                    I tried all three options i.e., running via strategy analyzer, via chart and via strategies tab. Also with ExitOnClose to false. I should be getting a buy order for this last Friday. I don't see that. The program does generate orders and works fine for prior weeks. Please let me know if you need any additional information.

                    Code:
                    #region Using declarations
                    using System;
                    using System.ComponentModel;
                    using System.Diagnostics;
                    using System.Drawing;
                    using System.Drawing.Drawing2D;
                    using System.Xml.Serialization;
                    using NinjaTrader.Cbi;
                    using NinjaTrader.Data;
                    using NinjaTrader.Indicator;
                    using NinjaTrader.Gui.Chart;
                    using NinjaTrader.Strategy;
                    #endregion
                    
                    // This namespace holds all strategies and is required. Do not change it.
                    namespace NinjaTrader.Strategy
                    {
                        /// <summary>
                        /// Enter the description of your strategy here
                        /// </summary>
                        [Description("Enter the description of your strategy here")]
                        public class SampleOrderTest : Strategy
                        {
                            protected override void Initialize()
                            {			
                                CalculateOnBarClose = true;
                            }
                    		
                    		protected override void OnBarUpdate()
                            {
                    			DayOfWeek week_day = Time[0].DayOfWeek;
                    			
                    			DayOfWeek buyDay = DayOfWeek.Friday;
                    			DayOfWeek sellDay = DayOfWeek.Monday;
                    			
                    			if(week_day == buyDay)
                    			{
                    				EnterLong(DefaultQuantity, "");
                    			}
                    			if(week_day == sellDay)
                    			{
                    				ExitLong("");
                    			}
                            }
                        }
                    }
                    You have CalculateOnBarClose = true;

                    That means that your Friday bar will close on Monday, the next day, which is when your trade will be generated.

                    Comment


                      #11
                      Hi Koganam,
                      Thanks for your insight. I am bit confused about when current day's bar will get processed by a strategy. I appreciate your insight on following couple question -

                      Option: CalculateOnBarClose = false
                      (a) With this option, this evening I ran the strategy (code below) via strategy analyzer after market hours (i.e., around 1-2 hours after market close). The strategy does not reach today's bar. It stops on 1 bar before today. I can see today's bar in the chart both with Yahoo and Kinetic (EOD) data feeds. When does today's bar will be available to a strategy via strategy analyzer? Don't know if it makes any difference, I am in Pacific Time zone.

                      Option: CalculateOnBarClose = true
                      (a) With this option, does it mean after Monday open, ninjatrader considers Friday bar as complete? My understanding was each day after market close, the bar would be considered by ninjatrader as closed. Looks like I was wrong. It would help if you can point me to any documentation on this from NT.

                      Hi JC -
                      My requirement is fairly simple. I want to run a strategy end of the day (i.e., after hours) on a watchlist, take a printout of generated orders and trade them MANUALLY the next day. Similarly for rotational/switching strategies, I want to run the strategy over weekend, take a printout of generated orders and trade them manually following week.

                      I will be using Ninjatrader for Futures account but for other accounts I will not. In all cases, the actual order placement will be manual.

                      Following is a sample strategy. I will appreciate if you can provide me instructions on what I should do so that each day after market hours (and over weekends), I can run strategies like this sample strategy on a watchlist and get a list of orders to follow thru manually. For equities, I will be using Yahoo/Kinetic (EOD).

                      Code:
                      #region Using declarations
                      using System;
                      using System.ComponentModel;
                      using System.Diagnostics;
                      using System.Drawing;
                      using System.Drawing.Drawing2D;
                      using System.Xml.Serialization;
                      using NinjaTrader.Cbi;
                      using NinjaTrader.Data;
                      using NinjaTrader.Indicator;
                      using NinjaTrader.Gui.Chart;
                      using NinjaTrader.Strategy;
                      #endregion
                      
                      // This namespace holds all strategies and is required. Do not change it.
                      namespace NinjaTrader.Strategy
                      {
                          [Description("Enter the description of your strategy here")]
                          public class SampleOrderTest : Strategy
                          {
                              protected override void Initialize()
                              {			
                                  CalculateOnBarClose = false;
                              }
                      		
                      		protected override void OnBarUpdate()
                              {
                      			DayOfWeek bar_day = Time[0].DayOfWeek;
                      			DayOfWeek buyDay = DayOfWeek.Thursday;
                      			DayOfWeek sellDay = DayOfWeek.Monday;
                      			
                      			Print("Proceesing bar........." + Time[0].Date.ToShortDateString());
                      			
                      			if(bar_day == buyDay)
                      			{
                      				EnterLong(DefaultQuantity, "");
                      				Print("BuyOn:" + Time[0].AddDays(1).Date.ToShortDateString() 
                      								+ "," + Instrument.FullName + ",@Price: " + Close[0]);
                      			}
                      			if(bar_day == sellDay)
                      			{
                      				ExitLong("");
                      				Print("SellOn:" + Time[0].AddDays(1).Date.ToShortDateString() 
                      								 + "," + Instrument.FullName + ",@Price: " + Close[0]);
                      			}
                              }
                          }
                      }

                      Comment


                        #12
                        Hello atrader123,

                        Using a strategy you would not be able to apply it to a watchlist, you would have to apply it to each instrument individually.

                        To apply it on a watchlist you may create an indicator that can print out the same values and use it inside the Market Analyzer window where it can be applied to a watchlist of instruments

                        http://www.ninjatrader.com/support/h...th_columns.htm

                        The session template controls the time frame that data is used inside the NinjaScript. You will need to select a session template that is for the hours you want to have data displayed on the chart

                        You can select a session template by going to the Tools -> Instrument Manager then select what instrument you would like to change and press the Edit button.Once insde the menu you can select the Session Template that you would like to view for example the "Default 24/7"

                        http://www.ninjatrader.com/support/h...nstruments.htm

                        You can view/edit/create session templates in the Session Manager window. You can access the Session Manager by going to Tools > Session Manager. Below is a link to the Session Manager section of our help guide.

                        * http://www.ninjatrader.com/support/h...on_manager.htm

                        Now that you are able to view data after market hours you can specify what time you would like to capture your data. The following link to our forums is a reference to using time filters to limit hours of trading that you may use.

                        http://www.ninjatrader.com/support/f...ead.php?t=3226

                        Let me know if I can be of further assistance.
                        JCNinjaTrader Customer Service

                        Comment


                          #13
                          Hi JC -
                          Thanks. I could be missing something. I am not able to figure out how the suggestion help me in solving the problem.

                          For example, my requirement is working off the daily charts using Yahoo/Kinetic (EOD) data. No intraday data. So do session templates still apply here? If it helps, my session template is currently set to 24/7 and I can see all daily bars fine in charts both in strategy analyzer as well as outside the analyzer. My computer timezone is set to Pacific TimeZone.

                          At this point, I gave up on trying to utilize NT order functionality to solve the problem. I wrote custom order classes which print out orders when the strategy triggers signals and stops. To close the remaining gap, it will help if some one from NT support answer the below questions from my earlier post.

                          Data feed - Yahoo / Kinetic EOD data
                          (a) What do I need to do/what is needed so that strategy analyzer runs below sample strategy (code in prior post) on today's bar as well? (Note: I will be running it after market close). You can see from the print statements, the strategy analyzer currently processes all bars except today's bar even though today's bar shows up on the chart. I have seen strategy analyzer processing today's bar sometimes (on same day after hours) but cannot figure out under what criteria it will process today's bar. Any guidance and pointers here will help.

                          (b) Option: CalculateOnBarClose = true. With this option, does it mean after Monday open, ninjatrader considers Friday bar as complete? My understanding was each day after market close, the bar would be considered by ninjatrader as closed. Looks like I was wrong. It would help if you can point me to any documentation on this from NT.

                          Regards,

                          Comment


                            #14
                            Hello atrader123,

                            A.) The Strategy Analyzer will only run on Historical data only with Calculate on bar close set to true. So you would not be able to run a daily time frame on today's date via the Strategy Analyzer to get the results.

                            http://www.ninjatrader.com/support/h...y_analyzer.htm


                            B.) With at daily time frame it means that OnBarUpdate() will get processed after the bar has closed. So if you had a order that needs to be submitted it would be submitted at the start/open of the next bar. For example using your sample above, your strategy will enter at open of the Monday bar, and exit on Tuesday bar at the open.

                            http://www.ninjatrader.com/support/h...onbarclose.htm
                            JCNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by atrader123 View Post
                              Hi JC -
                              Thanks. I could be missing something. I am not able to figure out how the suggestion help me in solving the problem.

                              For example, my requirement is working off the daily charts using Yahoo/Kinetic (EOD) data. No intraday data. So do session templates still apply here? If it helps, my session template is currently set to 24/7 and I can see all daily bars fine in charts both in strategy analyzer as well as outside the analyzer. My computer timezone is set to Pacific TimeZone.

                              At this point, I gave up on trying to utilize NT order functionality to solve the problem. I wrote custom order classes which print out orders when the strategy triggers signals and stops. To close the remaining gap, it will help if some one from NT support answer the below questions from my earlier post.

                              Data feed - Yahoo / Kinetic EOD data
                              (a) What do I need to do/what is needed so that strategy analyzer runs below sample strategy (code in prior post) on today's bar as well? (Note: I will be running it after market close). You can see from the print statements, the strategy analyzer currently processes all bars except today's bar even though today's bar shows up on the chart. I have seen strategy analyzer processing today's bar sometimes (on same day after hours) but cannot figure out under what criteria it will process today's bar. Any guidance and pointers here will help.

                              (b) Option: CalculateOnBarClose = true. With this option, does it mean after Monday open, ninjatrader considers Friday bar as complete? My understanding was each day after market close, the bar would be considered by ninjatrader as closed. Looks like I was wrong. It would help if you can point me to any documentation on this from NT.

                              Regards,
                              The day is closed when the session template says that it is, so if you are using 24/7, then today's bar will close tomorrow. Use a session template that closes during the day, and the bar should show up after hours.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              666 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              377 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              110 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              580 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X