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

High within a time range

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

    High within a time range

    Hi, without code, is it possible to set a strategy that would go long if there is a close higher than the high within a set time window?

    The main part of this is displaying the high say between 06.00 and 12.00. Is this possible without code?

    I know you can restrict your trading window by time, e.g. only trade if time is between 07 and 0800. What I want is for the variable to be based on time not the trading conditions if that makes sense.

    #2
    Hello Strewthmate,

    I have attached a screenshot with one approach to this. For the time filter you select Time -> Time Series on the left and Time -> Time Value on the right. The example in the picture checks highs in-between 6 and 7 PM.

    You check if High[0] is greater than Variable0 and if so the new High[0] is assigned to this Variable0.

    Then on Set2 you can check Close[0] against Variable0 and place orders.
    Attached Files
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      How could I do this but getting the high price from a back time range?
      e.g. it is 10 am and I want to check the High from the 5 am to 7 am time range period

      Thanks

      Comment


        #4
        Hello doniphon and thank you for your question.

        For this you will want to use the output of the MAX indicator instead of a single value from the High series. I am including documentation for the MAX indicator from the Help Guide.



        I am attaching a screenshot of the condition builder as an example. You will want to adjust the period to cover the time range. For example, if you had a 5 minute data series, you would want a period of 24 to cover the 2 hour period you mentioned.

        You will also want to check to see if the time is 7 AM in your example. Even if the time is currently 10 AM, if you check to see that the time held in Time[0] is currently 7 AM, then this will occur once during historical bar processing.

        Please let us know if there are any other ways we can help.
        Attached Files
        Last edited by NinjaTrader_JessicaP; 05-17-2016, 07:29 AM.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Hello,
          the logic is "everyday from 10 am to 11 am I want to enter long if the price crosses the high from 5 to 7 am period".
          The problem is I do not know how to set this high price into a variable. I could not check the time held in Time[0].
          And, is it possible to do it without counting bars?
          Thanks

          Comment


            #6
            Hello doniphon,

            If you would like to do this without counting bars, you can do so following along with the attached images. Please let me know if I can clarify any settings.

            Explanation of steps

            Steps 1-4 : If it's between 5 and 7, and the current high is greater than the greatest high so far, store it as the greatest high so far

            Step 5 : Review to make sure condition set 1 is ok

            Steps 6 : We're done with condition set 1. Let's move on to condition set 2.

            Steps 7-8 : If it's between 10 and 11...
            Steps 9-11 : ... and we cross over the greatest high between 5 and 7...

            Note: As true cross overs require two data series, in order to compare a data series to a value, we check to make sure we are rising and have not entered into a trade in the last 10 bars. This is equivalent to checking 10 bars for a crossover condition.

            Step 12 : ... and we found a highest value between 5 and 7 this morning (e.g. you didn't turn on Ninja at 8 AM) ...

            Step 13 : ... then enter long

            Steps 14 - 15 : Ensure our 2nd condition set is ok
            Attached Files
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Hello JessicaP,
              it does not run a backtest... It does, but no trades are placed.
              The Properties region is empty, is it normal?

              Comment


                #8
                Hello doniphon,

                This was not intended as a complete strategy, but rather was meant to extend the original post. We can see in the original post, for instance, a variable that is not reset at the end of the day.

                You can use a 3rd and fourth condition set to set Variable0 to 0 when the time is less than 5:00 AM or greater than 11:00 AM, and this will then give you trades in the strategy analyzer.
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Jessica,
                  I finally check the time at 7 am and get the Upper Donchian Channel value from X bars ago (depends on the timeframe). I do this because the High[0] series did not work well by storing the highest high of the time range.
                  Now I have another problem. I want to enter Long just when the price (Ask price in this case) crosses above the high of the range) but all the combinations I have tried did not work, the trade is always placed on the next bar (at open price). Even when the CalculateOnBarClose method is set to false.

                  Thanks for your help.

                  Comment


                    #10
                    Hello doniphon,

                    I would begin by trying a trivial case and building on it. To make further questions and investigations easier, I would highly recommend making a new strategy that is just this :

                    • If the time is 10 AM
                      • Enter a long position

                    That said, when using historical data or backtesting, Ninja will not calculate intra-bar. Using historical data, orders will always trigger after bars close.
                    Jessica P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Balage0922, Today, 07:38 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post Balage0922  
                    Started by JoMoon2024, Today, 06:56 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post JoMoon2024  
                    Started by Haiasi, 04-25-2024, 06:53 PM
                    2 responses
                    19 views
                    0 likes
                    Last Post Massinisa  
                    Started by Creamers, Today, 05:32 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post Creamers  
                    Started by Segwin, 05-07-2018, 02:15 PM
                    12 responses
                    1,786 views
                    0 likes
                    Last Post Leafcutter  
                    Working...
                    X