Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High/low based on duration

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

    #16
    Try this. It should work.
    Attached Files
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      You guys are terrific!! Love you!! This works great. I see I needed to add
      private
      double hh = 0;
      privatedouble ll = 0;

      in the variables region.

      One other question...I need to bring this into a strategy I'm building, should I keep it as an indicator and just try and call it in the strategy, like I might call the CCI? Or should I try and copy in the code?

      Comment


        #18
        Either or will work.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Hi Josh and Ben

          I'm having difficulty getting comparisons to work with the highest high and lowest low we plotted. It keeps making NT crash. This is what I'm doing that it doesn't seem to like the following as conditions for entry:

          int barssincebarrier = GetBar(startDateTime);

          if highlow().LowestLow[0] > (MIN(Low, barssincebarrier)[0]) && etc.

          and it also doesn't respond to:

          if ((highlow().HighestHigh[0] - highlow().LowestLow[0]) < 80 * TickSize)

          Can you tell me what is wrong with these two statements? I've just referenced the indicator you helped me with in these statements to get to the values.

          All I want to do is check that since the end of the highesthigh/lowestlow period price has moved either higher or lower than those barriers as a condition of entry. I also want to check that the distance between the high and low barriers is less than 80 pips.
          Last edited by Red Fish; 09-05-2008, 07:48 AM.

          Comment


            #20
            I suspect there may be performance issues with the loop. Try just migrating the code over to your strategy and running it from there.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              Hi Josh

              I tried copying in the code from the indicator to the strategy, and it doesn't like the syntax. I checked it through, and I can't see any differences, so I don't know why the syntax is okay in the indicator but not in the strategy. Can you have a look at it please?
              Attached Files

              Comment


                #22
                Code:
                Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "HighestHigh"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "LowestLow"));
                You can't create plots in a strategy, but for this case you don't need to. Delete those lines along with these:
                Code:
                HighestHigh.Set(hh);
                LowestLow.Set(ll);
                To use your values just reference the ll and hh.
                Josh P.NinjaTrader Customer Service

                Comment


                  #23
                  Hi Josh, I have done that now, so no syntax errors. But it hasn't changed the way the strategy works... it still just freezes NT and I have to end the program and relaunch.

                  Comment


                    #24
                    I checked all the other elements in the strategy work...it's just when I add this one in that it freezes.

                    Comment


                      #25
                      Decrease the amount of data you are backtesting on. Please note: The way the code is designed if you are running it on a chart that never has a bar that is timestamped exactly as you have defined myEndTime then it will just loop through every single bar on your chart. CPU intense. It just keeps going and going hence the freeze.

                      Make sure your myEndTime actually exists as a timestamp on a bar in your chart.
                      Last edited by NinjaTrader_JoshP; 09-05-2008, 10:00 AM.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Hi Josh, I am only testing it on 60 days of data.

                        Comment


                          #27
                          60 days can easily be a ton of bars. The issue is the one about finding a bar with the specific timestamp that you defined as the EndTime. Please look at a chart manually first to ensure that such bars exist on a consistent basis. Your code will go through that loop every time your StartTime is met. If it can't find the bar associated with the exact EndTime it will go all the way to the beginning of the chart running through hundreds of calculations. Multiplied by doing that 60 times. You'll run out of computer resources pretty fast.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #28
                            Hi Josh, thanks for your replies. I just went through the txt data file that feeds NT for the last 30 days of the time frame I was looking at and it found 22 instances of that timestamp EndTime.

                            Comment


                              #29
                              Red Fish,

                              Then you need to just debug what is happening in your strategy and why it is hanging. http://www.ninjatrader-support.com/v...ead.php?t=3418
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #30
                                Josh, but am I right in thinking I can't get any output in the output window until it has run on a chart first...that's how I've been using the output window - compile the code and then run it on a chart then go to the output window. As I can't run it on a chart without it locking up my whole computer I can't see how I can view anything on the output window.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                670 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                379 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                111 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                575 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                582 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X