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

New 5day or week high

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

    New 5day or week high

    It's been a very long time since I've worked on a strategy in NT so this is probably very basic. I looked through the manual. How would you create an entry condition that requires a new 5day high and just a new current day high?

    #2
    zachj, thanks for the post - the current day could be accessed per default via the CurrentDay.OHL indicator in NinjaScript - http://www.ninjatrader.com/support/h...nt_day_ohl.htm

    For the current week, you would need to custom code a condition to keep track of it - this is not inbuild standard but on our suggestion list for potential future enhancement.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Would I do something like..

      private double WeekHigh()

      {
      return (CurrentDayOHL().CurrentHigh[0] > PriorDayOHLC().PriorHigh[0] && CurrentDayOHL().CurrentHigh[0] > PriorDayOHLC().PriorHigh[1] && CurrentDayOHL().CurrentHigh[0] > PriorDayOHLC().PriorHigh[2] ........)
      }

      private void WeekHighMethod()
      {
      if (Close[0] > WeekHigh())
      {EnterLong()}
      }

      I think putting the PriorHigh[1] sends it back 2 days? And PriorHigh[2] is 3 days back.

      Comment


        #4
        zachj, the index you apply would be based on the bars, so would not refer to 1 / 2 days back but literally the bars of the series you're working on.

        To track you can start working for example with this snippet, it would reset the track on Monday for the new week -

        if (Time[0].DayOfWeek == DayOfWeek.Monday && Bars.SessionBreak)
        trackCurrHigh = High[0];

        if (High[0] > trackCurrHigh)
        trackCurrHigh = High[0];
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I'm not understanding what that is doing and don't see anything in the manual about trackCurrHigh?

          I guess that is picking up the high starting from monday but that will do we no good if it's wed im trying to look back 5 trading days. I can't believe there is no way to have it recognize the day high say 3days back.

          What about creating and index 1
          Add(PeriodType.Day, 5); This would make a 5day bar I think.

          {
          if (Close[0] > Highs[1][0])
          {EnterLong()}
          }

          Comment


            #6
            zachj, correct you could add a daily series to the script as well and reference it. My code was custom and not taken from any manual, it would track the developing current weekly high but not on a rolling basis.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              So when I add Index 1 as mentioned below, a 5day bar, what is the primary bar set at where can I see this or adjust the primary? Will it just be whatever chart time period I have pulled up, say I have a 5minute chart up. Or is this controllable in the backtest area? I wasn't quite understanding that from the manual.

              Comment


                #8
                Yes, correct - the primary would always be your charted / backtested main series.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rene69851, 05-02-2024, 03:25 PM
                1 response
                20 views
                0 likes
                Last Post rene69851  
                Started by ETFVoyageur, Yesterday, 07:05 PM
                5 responses
                44 views
                0 likes
                Last Post ETFVoyageur  
                Started by jpeep, 08-16-2020, 08:31 AM
                13 responses
                487 views
                0 likes
                Last Post notenufftime  
                Started by realblubb, 04-28-2024, 09:28 AM
                2 responses
                32 views
                0 likes
                Last Post realblubb  
                Started by bmarovets, Today, 06:33 PM
                0 responses
                12 views
                0 likes
                Last Post bmarovets  
                Working...
                X