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

Trade Hours / Time / Analyzer Effeciency

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

    Trade Hours / Time / Analyzer Effeciency

    My overall goal is maximize the profit potential of my capital. I've recognized I can let my capitol work a strategy all day with a set of parameters or for 7 - 1 hour periods with different parameters. I'm finding in my beginning stages of strategy development that the latter has a much higher return. I've also noticed that the optimizer runs much faster if it's only working with an hour of data that is set by the trading hours but...

    I'm having a hard time controlling the trading hours or data worked through with parameters or code. I've also seemed to break a few things by trying to update an existing set of trading hours through code or UI with a lot of strange behavior. Strategies not running or running the wrong set of hours/data almost as if it's cached.

    I'm hoping someone can point me on the right direction here.

    I would like to accomplish two things.

    1. Control of trading hours by code that can be set as parameters?
    2. Maximum strategy analyzer efficiency.
    • Can I force it to only iterate through an hour at a time after my hours have been modified?
    • Can I force it to stop iterating over that day if my code if statements are controlled by 'time'


    Any details on the logic of how this all works would be great as well. Is the trading hours loaded during defaults? Requires state change? Can this be forced... Will it always reset the data loaded? Is this less efficient....?

    Thank you in Advance!

    #2
    Hello Dragon989,

    The hours a strategy can trade can be controlled with time filters in the logic.

    Below is a public link to a reference sample that demonstrates.


    When you mention "can I force it to only iterate through an hour at a time after my hours have been modified?" are you asking how to optimize the start time?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Yes - I'm very familiar with how how to use time filters for applying trading logic, however; this does not help with the overall efficiency of the strategy analyzer and limiting time it needs to run. Why run over the entire day if only one hour is relevant.

      Not sure what you mean by optimize the start time but always interested in more information that might assist.

      Thank You!

      Comment


        #4
        Hello Dragon989,

        It is not supported to change any data series parameters programmatically.

        You would need to use the normal trading hours template and limit the trades based on logic.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Is there a way I can force the end of a daily session so the analyzer will move onto the next day? Basically if it's after 10AM my code will do nothing else today.. move on to the next please.

          Comment


            #6
            Hello Dragon989,

            If you program a time filter then then logic will not process outside of the set times. If only one hour is relevant than program a time filter that does that.

            What about the time filter is not working for you? Can you show us the filter that you tried to use that is not doing what you expect? If so, what do you expect it to do?
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              The goal is to use the same capital over and over again - Could let it run all day but so much more opportunity.

              I'm trying to accomplish the following with the least amount of manual steps and processing time as possible. I want to test my strategy and all of the other parameter ranges against.....

              What are the returns when... Short Only, Long Only or Both.

              Any time combination possible on 30 minutes.
              • - Entry and Exit Between - 6:30 - 7:00, 7:00 - 7:30, 6:30 - 7:30, 6 - 9, 8 - 1 (Fully Optimized on valid combinations)


              Valid time combinations like above but optimizing the entry time period with the sell by time period.
              • - Entry between 6:30 and 7:00 must exit by 8:00 and so forth.


              Semi related -
              • Is it possible to pivot the optimizer - show me the top 10 optimized returns for traders between 6:00 - 7:30, 7:30 - 8:00 etc.
              • Is this the only way to create a non ranging parameter in the UI? That persists to things like the Analyzer Settings Tab. I found a string does not display or allow for ranging like an integer.


              Code:
              		[Browsable(false)]
              		public int EndTime
              		{ get; set; }
              		
              		[NinjaScriptProperty]
              		[Display(Name="EndTime", Order=2, GroupName="Parameters")]
              		public string EndTimeHold
              		{ 
              			get { return EndTime.ToString(); }
              			set { EndTime = int.Parse(value); } 
              		}
              Happy to hear any other ways to solve this as well.
              Last edited by Dragon989; 10-02-2018, 05:25 PM.

              Comment


                #8
                I answered this question about optimizing different time frames in another thread. You could use the same concept on how to optimize different time frames to determine if you are short, long, or both.



                Is it possible to pivot the optimizer - show me the top 10 optimized returns for traders between 6:00 - 7:30, 7:30 - 8:00 etc.
                This is not currently possible.
                Is this the only way to create a non ranging parameter in the UI? That persists to things like the Analyzer Settings Tab. I found a string does not display or allow for ranging like an integer.
                What do you mean by ranging? What would you like to display in the parameters and what range of settings do you want to be able to select?
                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  I want to display a single input field. No range settings.

                  Please note all the questions are about input parameters that are tested in the analyzer and are input settings when the strategy runs live.

                  Additionally - Is there a way to display a pick-list, Would still be a single field without range settings that give me the option to choose predefined strings.

                  Can you point me in the direction for the best enum assistance as I think that achieves the following. End goal would be to be able to have the analyzer iterate through a list of things that are displayed in text. Like long, short, undershort that would control different modes/actions in my script. I've done some searching but I'm confused with the long history of information.

                  Thanks!

                  Comment


                    #10
                    You are correct, a great way to do this will be with enums. You could optimize an enum by implementing something like the attached script.

                    Let me know if you have any questions.
                    Attached Files
                    Josh G.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank You!!

                      Does the analyzer iterate and/or always iterate across everything in the enum list? Can a range be set as this possibly could solve the issue below or maybe a better way?

                      I'm probably missing something obvious here but how do you setup a parameter for time? I would like to be able test a start trading time at 6:30, 7:00, and so on. I've been using values such as 63000 but an increment value won't work. I did consider using minutes with some conversion but then the human readability becomes an issue.

                      Comment


                        #12
                        You would need to select which items in your enums list you would like to optimize, otherwise they would not be included in the test. I do not think it would be possible to set a range of enums in the C# language.

                        As far as optimizing different starting times I would do something like I described in the follow post.

                        Josh G.NinjaTrader Customer Service

                        Comment


                          #13
                          How do I properly convert the enum values to something usable for operators such as strings. I've found many ways to accomplish this but nothing that persist correctly in the Startegy Analyzer. It looks like it runs the test correctly and shows it in the roll-up report but does not in other areas such as trades or the chart.

                          Comment


                            #14
                            It looks like the chosen Enum parameter does not persist at all regardless of any conversion when looking at the detailed analyzed results. What am I missing?

                            Comment


                              #15
                              Enums do not need to be serialized. Is that what you are trying to do?

                              Why do you need them converted to string?
                              Josh G.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by funk10101, Today, 12:02 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post funk10101  
                              Started by gravdigaz6, Yesterday, 11:40 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by MarianApalaghiei, Yesterday, 10:49 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by XXtrader, Yesterday, 11:30 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post XXtrader  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              28 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X