Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intraday strategy using Daily indicator

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

    Intraday strategy using Daily indicator

    How can I use value of a Daily indicator, e.g., Daily ATR in my criteria for an intraday strategy?

    E.g., to prevent from entering when a move is extremely extended, I want the intraday Strategy to enter a long position only if the closing price on 15 minute bars has not travelled more than 60% of the Daily ATR. So, I need to compare the close on the current 15 minute bar to today's open + Daily ATR.

    #2
    You could add a daily bars to your strategy.

    Information on multi-time frame strategeis - http://www.ninjatrader-support.com/H...struments.html

    You could get OHL values for the session build from intraday data using the CurrentDayOHL() method.

    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for response. The link you gave appears to be for hand-coding. Is there a way to do this in the builder interface wizard?

      Comment


        #4
        Unfortunately this is not supported in the wizard.
        RayNinjaTrader Customer Service

        Comment


          #5
          Hi Ray, has there been any new additions which make it easier to make an intraday strategy using a daily indicator?

          Also, the linked in post 07-04-2008, 08:12 AM are dead.

          Thanks

          Comment


            #6
            Hi Scotty, this would still be an item requiring manual coding. We ship NinjaTrader though with a practical example of such a script you could review on your local install, just open up the SampleMultiTimeFrame script in your NinjaScript editor (Tools > Edit NinjaScript > Strategy).

            The updated links would be -



            Comment


              #7
              Thanks Bertrand.

              If I am going to be Adding an indicator under
              Code:
              protected override void Initialize()
              , where the indicator will not be using the primary bars object, do I have to add it in a different way?

              E.g., if I add an indicator this way, will it work for both the primary bars object and any other secondary bar object(s)?

              Code:
              Add(MyIndicator(Period, StdDevThresh));

              Comment


                #8
                Hi Scotty, this would just add the indicator in for display purposes. So same as if you add in the study manually to your chart - it would not be calculating it for any additional series though, it would run as coded into the study itself. So if the indicator would add for example a series and calculate / plot a value based on it > that would be replicated in the Add() call by the strategy.

                Comment


                  #9
                  Thanks Bertrand.

                  What I'm finding is that I am able to add the indicator when I use:

                  Code:
                  Add(MeanderIndicator(Period, StdDevThresh));
                  However, when I try and pass it my secondary bar series, it no longer shows any indicator. E.g., no new panel appears. This is the syntax I am trying to use,

                  Code:
                  Add(MeanderIndicator(BarsArray[1],Period, StdDevThresh));
                  I am able to add the indicator manually using a hidden bar series but I would like it to add automatically when I enable the strategy on the chart.

                  Furthermore, how would I make the indicator appear on the primary panel by default (rather than appearing in a new panel)?

                  Thanks

                  Comment


                    #10
                    Hello scottyheist,

                    I believe the problem you are running into is the order in which you are trying to provide data to your external indicator.

                    In this case you are trying to get the BarsArray[1] to pass to an indicator. Because this is all happening in Initialize I believe that this is where your problem is.

                    The data series that is being passed is not created yet, initialize only happens once so if the provided data is null the indicator would not plot.

                    The usual way to accomplish what you are trying to do would be instead of passing the bar series to the indicator, only call the indicator from the strategy and do your BarsArray[1] logic from within the indicator its self.

                    To make an indicator appear on a chart panel instead of the second panel there are a couple of ways to do this.

                    If you are coding this into an indicator, generally you would specify the Overlay = true; in your initialize and this will overlay on the price panel.

                    You can specify a PanelUI if you are adding from a strategy.

                    There is an excellent example of plotting from a strategy that shows how to do this located here:

                    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


                    Please let me know if I may be of additional assistance.

                    Comment


                      #11
                      Hi Jesse,

                      Thanks for your response.

                      Regarding the first half of your reply, I have now added a secondary bar series such that:

                      Code:
                         protected override void Initialize()
                              {
                      			Add(PeriodType.Day, 1);
                                  Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "VSLow"));
                                  Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "VSMid"));
                                  Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "VSHigh"));
                                  Overlay				= false;
                              }
                      Since this indicator will be used on an intraday chart, am I supposed to reference this secondary series in the same way as I was doing before, i.e., within the OnBarUpdate function?

                      Within my OnBarUpdate I have the following, but I think this may be incorrect because the indicator isn't showing anything on the chart. It was working before when I was using it on the primary series.

                      Code:
                      protected override void OnBarUpdate()
                              {
                      			if (CurrentBar < (period+1)) return;
                      			
                      			
                      			double sumPrice = 0;
                      			double avgsumPrice = 0;
                      			
                      			for (int CountA = 0; CountA < period; CountA++)
                      				
                      			{
                      				
                      			//We sum all of the price data
                      			//Close
                      			sumPrice = sumPrice +  (Closes[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      		
                      			//Open
                      			sumPrice = sumPrice +  (Opens[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      			//High
                      			sumPrice = sumPrice +  (Highs[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      			//Low
                      			sumPrice = sumPrice +  (Lows[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      				
                      			}
                      			
                      			avgsumPrice = sumPrice/(4*period);
                      			
                      			//Now we calculate the SD
                      			
                      			double TempStdDev = 0;
                      			double TempStdDevSum = 0;
                      			sumPrice=0;
                      			
                      			for (int CountA = 0; CountA < period; CountA++)
                      				
                      			{
                      				
                      					//Close
                      			sumPrice = sumPrice +  (Closes[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      		
                      			//Open
                      			sumPrice = sumPrice +  (Opens[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      			//High
                      			sumPrice = sumPrice +  (Highs[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      			//Low
                      			sumPrice = sumPrice +  (Lows[1][CountA]-Closes[1][CountA+1])/Closes[1][CountA+1];
                      				
                      			
                      			TempStdDevSum = TempStdDevSum + Math.Pow(sumPrice - avgsumPrice,2);	
                      				
                      			}
                      			
                      			TempStdDev = Math.Sqrt(TempStdDevSum/(4*period - 1));
                      			
                      			
                      			
                      			
                                  // Use this method for calculating your indicator values. Assign a value to each
                               
                                  VSLow.Set(Closes[1][0]*(1 + (avgsumPrice-TempStdDev*stdDevLimit)));
                                  VSMid.Set(Closes[1][0]*(1+avgsumPrice));
                                  VSHigh.Set(   Closes[1][0]*(1  +   (avgsumPrice+TempStdDev*stdDevLimit)   ) );
                              }

                      Comment


                        #12
                        Hello scottyheist,

                        Thank you for the reply.

                        So it looks like your adding a 1 day data series and then referencing the second data series which should be the 1 day.

                        For this I would like to know have you looked in the Output Window (Tools -> Output window) after you refresh the script with the output window open, is there any output?

                        How many days are you loading on the chart of data? is it enough to cover the period you are setting?

                        Have you used Print() statements along with the output window to ensure that the area where the dataseries are set is being reached?

                        Generally when you don’t see something plotting a good first step is to open the output window and use print statements.
                        You can place a print statement where you think an error may be and run the script, if the print places text into the output window you can move the print after the next statement in your logic and repeat. When you run into the place where it does not print thats where the problem is. you can also do this for your values to make sure you are returning a value.

                        Here is some general information regarding Debugging NinjaScript


                        I look forward to being of further assistance.

                        Comment


                          #13
                          Hi Jesse,

                          Just to recap, I intend to use this indicator on a 1-min chart (but with around 30 days loaded).

                          Since the indicator will be used on a 1-min chart, then the primary bars array will be 1-min bars, but my indicator uses information based on daily bars, which is why I am adding it as a secondary series.

                          Thanks for your debugging tips - I'll go through those now.

                          Cheers

                          Comment


                            #14
                            Hi Jesse,

                            Just for closure, I determined what the problem was.

                            I had
                            Code:
                            if (CurrentBars < (period+1)) return;
                            whereas I should have had

                            Code:
                            if (CurrentBars[1] < (period+1)) return;
                            because I was referencing the secondary bar series in my indicator!

                            Thanks for your help anyway.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            639 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            366 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            107 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            569 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            572 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X