Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

autostrategy for time of day buys and sells

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

    autostrategy for time of day buys and sells

    I couldn't find the information on vids on how to set up a strategy using just time of day? I have tried a couple of different approaches but everytime I try and activate the conditions box. The box doesn't load.
    I don't want to use any indicators - I just want to buy a group of futures near 4pm and sell them at 7:30am.
    Would someone be willing to post a tutorial or screen shots to get me started.
    Thanks,
    Mike

    #2
    Hello Mike,
    Welcome to the forum and I am happy to assist you.

    You can compare the bar time to filter your trading time. Unfortunately there are no videos but you can refer to this sample code which further illustrates it.


    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      errors in code

      Hi Joy,
      I downloaded the zip file but when I went to import it into my strategy I got a message telling me it had errors in it that need to be fixed. Suggestions?
      thanks mike

      Comment


        #4
        Hello gonetowindsurf
        Thank you for writing in.

        Please follow the instructions below to see where the errors are coming from after compiling the indicator. This will allow you to debug the indicator/strategy or remove it from your PC. If you are wondering why you receive an error when compiling only one indicator, it is because NinjaTrader compiles all indicators and strategies- not just one.
        • Open NinjaTrader
        • From the Control Center select the Tools menu--> select the Edit NinjaScript menu item--> select Indicator
        • Select an indicator and double click on it.
        • A new window will appear and you will need to right click in the window and select Compile to compile the indicators.
        • At the bottom of the window a new section will appear where you can find the error locations.
        • From there you have the option to remove the indicator or debug it.

        Here is a video of this process:
        http://screencast.com/t/K3plVBblUy
        Also here is a forum post that describes the process and offers ways to resolve the situation:
        http://www.ninjatrader.com/support/f...ead.php?t=4678

        If you are unsure as to what the error is indicating, please send me a screenshot of the error with the name and description fields clearly readable.
        To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

        Please let me know if I can provide any further assistance.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Ninja_Support, please correct me if I am wrong.
          In your strategy, under the OnBarUpdate() section, you can have something like this

          if (ToTime(Time[0]) == ToTime(15, 55, 0))
          {
          // Buy a group of futures

          }

          if (ToTime(Time[0]) == ToTime(7, 30, 0) )
          {
          // Sell the group of futures

          }

          Comment


            #6
            How about this?

            Hi Joy,
            I am going to just delete all the sample strategies and reload the download you provided. They are just sample scripts that I have no use for - make sense?
            mike

            Comment


              #7
              well that didn't work

              Apparently I cannot delete a strategy until i fix the error? It would be simpler just to punt it - not sure i reeeeely want to try and figure out an error - would rather just start from jump again - no? I am not the sharpest tool in the shed. Is there annny other way other than trying to find an error?
              mike

              Comment


                #8
                • Open NinjaTrader
                • From the Control Center select the Tools menu--> select the Edit NinjaScript menu item--> select Indicator
                • Select an indicator and double click on it.
                • A new window will appear and you will need to right click in the window and select Compile to compile the indicators.
                • At the bottom of the window a new section will appear where you can find the error locations.
                can you post a picture of your screen after compiling a random indicator ?

                Marco

                Comment


                  #9
                  Mike,

                  I also got the impression you were using the StrategyWizard to create your strategy, aren't you ?
                  Just making sure we're not bombarding you with all sorts of C# code which you aren't familiar with.

                  Marco

                  Comment


                    #10
                    Mike, you must delete the strategy or indicator that gave you the error while compiling, first. The way to do that is go to Tools -> Edit NinjaScript -> Strategy. You will see a list of strategies. Select the strategy that is giving you the error and click "Delete". After deleting the script, you then click "Cancel" to get out of the Edit Ninjascript menu. Once you delete the script that gave you the error, you would be able to compile other scripts.

                    Hope this helps.

                    Comment


                      #11
                      Hello gonetowindsurf,
                      So that I can assist you further can you send a contact number to support[AT]ninjatrader[DOT]com


                      Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.



                      @mhaus Yes, you can have that code on OnBarUpdate.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        Here is my error message - i also have a gazillion codes that are incorrect

                        #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 overnight : Strategy
                        {
                        #region Variables
                        // Wizard generated variables
                        // User defined variables (add any user defined variables below)
                        #endregion

                        /// <summary>
                        /// This method is used to configure the strategy and is called once before any strategy method is called.
                        /// </summary>
                        protected override void Initialize()
                        {
                        CalculateOnBarClose = false;
                        }

                        /// <summary>
                        /// Called on each bar update event (incoming tick)
                        /// </summary>
                        protected override void OnBarUpdate()
                        {
                        }

                        #region Properties
                        #endregion
                        }
                        }

                        #region Wizard settings, neither change nor remove
                        /*@
                        <?xml version="1.0" encoding="utf-16"?>
                        <NinjaTrader>
                        <Name>overnight</Name>
                        <CalculateOnBarClose>False</CalculateOnBarClose>
                        <Description>Enter the description of your strategy here</Description>
                        <Parameters />
                        <State>
                        <CurrentState>
                        <StrategyWizardState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                        <Name>Flat</Name>
                        <Sets>
                        <StrategyWizardStateSet>
                        <Actions />
                        <Conditions />
                        </StrategyWizardStateSet>
                        </Sets>
                        <StopTargets />
                        </StrategyWizardState>
                        </CurrentState>
                        </State>
                        </NinjaTrader>
                        @*/
                        #endregion

                        Comment


                          #13
                          When in doubt - reload

                          I am going to uninstall and then re install and see if i can start fresh -

                          Comment


                            #14
                            Please email us at support if you need further assistance on this.

                            -Brett

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bortz, 11-06-2023, 08:04 AM
                            47 responses
                            1,604 views
                            0 likes
                            Last Post aligator  
                            Started by jaybedreamin, Today, 05:56 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post jaybedreamin  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            6 responses
                            18 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by Jon17, Today, 04:33 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post Jon17
                            by Jon17
                             
                            Started by Javierw.ok, Today, 04:12 PM
                            0 responses
                            13 views
                            0 likes
                            Last Post Javierw.ok  
                            Working...
                            X