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 Make Entry Time A Variable?

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

    How To Make Entry Time A Variable?

    Hi,

    I really want to see if there are any patterns in the time my system enters a trade i.e any parts of the day that are more profitable to start trading than others.

    There are 2 ways i can think to do this.

    1/ Make Time a variable and optimize, but when ever i put in a time format 13:00 etc it rejects it.

    2/ Take the Trades TAB and export it to excel and sort by time. But the format Ninja writes the trades is dd/mm/yyyy hour:minute.. so if you put this in excel and sort these values it just does it by date first which isnt relevent.

    Can you tell me how i can analyse which entry times are most efficient. This is a key part of any system design. I assume theres a basic way?

    Thanks

    #2
    Hello Tomhgriff1,

    To optimize a time, you would need to use an int variable that can be incremented.


    You could also create an hour int variable, minute int variable, and optionally second int variable. This would allow for finer control of the minutes, for example if you wanted to limit the value between 0 and 60.
    Support for the development of custom automated trading strategies using NinjaScript.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply, but still not doing what i want. I created an Int variable.
      Then in the Strategy Wizard did

      Time Series < (User defined Inputs) "Hour"

      (which is intended to get the system to only take a setup before a certain time and it works when i write in a number such as 16:30 etc)

      and it says

      "Return type of left expression "DateTime" and right expression "Int32" do not match

      Comment


        #4
        Hello Tomhgriff1,

        Are you using ToTime() on the datetime object you are comparing as demonstrated in the links I have provided?

        Alternatively are you using the int as the hour parameter when creating a new datetime or timespan object?

        In other words, are you comparing like objects with like objects?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          I am using the strategy wizard. I dont want to change the code because then i cant use the wizard again.

          I currently have this


          ToTime(Time[0[) == ToTime (8,0,0)

          But there is no option to make the time value a variable, there is just a box to write the time in.

          Attached Files

          Comment


            #6
            Hello Tomhgriff1,

            The page to create variables is on the previous page labelled 'User Defined Inputs'. The screenshot you have shown is from the 'Conditions and Actions' page.

            Below is a link to a video that demonstrates how to use the Strategy Wizard.
            Understand the fundamentals of basic strategy creation by developing an actual strategy using the NinjaTrader Strategy Wizard.3:23 Strategy Wizard Overview7:...



            Just a heads up, the Strategy Wizard is capable of creating very simple scripts. More complicated concepts such as optimizing over inputs that are not typically optimizable are more advanced than what the Strategy Wizard is able to do and may require that you unlock the script and code manually.
            This would also be the case with any math that needs to be added to the script.
            Last edited by NinjaTrader_ChelseaB; 11-28-2016, 08:24 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi,

              Yes i know this. My point is there is no drop down to select my Time variable. I have all my variables setup on the "User Defined Inputs"

              Comment


                #8
                hello,

                do you have any suggestions please?

                You can see here i have "hour" as a variable



                But in the Wizard it doesnt allow me to select Hour as a variable. I can only write in a fixed value

                Attached Files

                Comment


                  #9
                  Hello Tomhgriff1,

                  This is correct. There is no DateTime object User Defined input in the Strategy Wizard of NinjaTrader 7. (There is in the Strategy Builder of NinjaTrader 8)

                  You would need to unlock the script and use the hour variable and minute variable and compare this with a ToTime() of the Time[0] value. (Or use a new TimeSpan object)
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Have you looked at the Periods tab in the Strategy Analyzer?

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Clevchin, Yesterday, 12:57 PM
                    16 responses
                    45 views
                    0 likes
                    Last Post Clevchin  
                    Started by DawnTreader, 05-08-2024, 05:58 PM
                    53 responses
                    311 views
                    0 likes
                    Last Post DawnTreader  
                    Started by grazz, 07-28-2017, 06:11 PM
                    27 responses
                    6,848 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Started by frslvr, Today, 11:36 AM
                    4 responses
                    15 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by tkaboris, 07-15-2024, 01:42 PM
                    13 responses
                    25 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X