Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding a Daily Indicator Filter

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

    Adding a Daily Indicator Filter

    Hi Folks,

    I am having a little trouble getting this to work with a Array. Attached is the sample MA cross over strategy.

    What I would like to try is to use the Daily LogReturnsZScore set to COBC = False (so it will fluctuate moment by moment) and use it as a broad filter before all my other conditions will fire intraday.

    For example, for Longs I may want to have the Daily LogReturnsZScore while in COBC = False to be 0.30 or greater before executing other conditions for a trigger to go long. Then, the exact opposite for Shorts.

    My issue is that I have typically used only the current bar series for conditions. I have played with Bar Arrays in the past and got them to work but never quite right. So, I decided to just keep the code clean without using Arrays (thereby having a lot less to go wrong/break). However, I like this idea and with just one Array condition I think it may be ok for my purposes.

    I have attached the stategy and the LogReturnsZScore indicator.

    Could you show what should be added to the sample MA strategy below to allow for this please (if you could highlight the sections you change in the code that would be great)?

    Attached Files
    Last edited by birdog; 03-29-2014, 09:57 AM.

    #2
    Hello birdog,

    Thank you for your post.

    I made edits to the LogReturnsZScore for a 1 Day Period Type, but what is checked before the other conditions like SampleMaCrossOver conditions? Is it the following?
    Code:
    				if (highlightBreach)
    				{
    					if (myzscore > sDLineValue || myzscore < sDLineValue*-1) PlotColors[0][0] = Color.Red;
    					else PlotColors[0][0] = Color.Gray;
    				}
    Attached Files

    Comment


      #3
      Hey Patrick,

      Thanks. Oh. The @SampleMACrossOver is the strategy and thh LogReturnsZScore is a indicator I was wanting to have a Daily BarArray for the additional filter. I was hoping to see if you could place necessary code in the @SampleMACrossOver strategy to get the ZScore Daily COBC false to be a filter for it. So, the @SampleMACrossOver is the strategy with the other condition.

      Does that help?

      Comment


        #4
        Hello birdog,

        Thank you for your response.

        What is the filter condition from the LogReturnsZScore?

        Comment


          #5
          Daily Bars set to COBC=False with lookback period of 15 days -- The current day bar above 0.30 for Longs and below -0.30 for Shorts (since it would be set to COBC=False it would fluctuate throughout the day).

          I think I touched on all the items for that indicator with that above statement. Look good?



          Originally posted by NinjaTrader_PatrickH View Post
          Hello birdog,

          Thank you for your response.

          What is the filter condition from the LogReturnsZScore?

          Comment


            #6
            Hello birdog,

            Thank you for your response.

            An example of the SampleMaCrossover with your ZScore indicator used as a filter is attached to this post.
            Attached Files

            Comment


              #7
              Hey Patrick,

              I am looking at it. Thanks. If I use a 5 min. chart/bar for the current series, then it would calculate the 10 and 25 MA from the 5 min. chart/bars. However, it looks like here the ZScore would still be calculated from the selected 5 min. chart/bar current series too. What I am really trying to do is have the 10 and 25 MA be from the selected 5 min (as a example) chart/bar series BUT then have the ZScore look a a BarArray that is set to look at the Daily chart/bar series (not the primary one) with COBC=false, looking 15 Daily bars back.

              I don't see the BarArray or reference to the ZScore Daily series etc?

              Sorry if I am missing something.

              You know what I mean?

              Comment


                #8
                Hello birdog,

                Thank you for your response.

                The LogReturnZScore has been provided with the daily bar as the bar it calculates on already. I will provide the full package as a .zip here.

                Alternatively, just use BarsArray[1] after addin ghte Daily period type to the strategy: http://www.ninjatrader.com/support/h.../barsarray.htm
                Attached Files

                Comment


                  #9
                  Ok. How do you add a BarArray so it is COBC False with the primary is series is COBC True?

                  Comment


                    #10
                    Hello birdog,

                    Thank you for your response.

                    You would need to use the following in the strategy:
                    Code:
                    // Initialize()
                    CalculateOnBarClose = false;
                    
                    // OnBarUpdate()
                    if(BarsInProgress == 0 && FirstTickOfBar)
                    {
                    // Process Primary Series
                    }
                    if(BarsInProgress == 1)
                    {
                    // Process Secondary Series
                    }
                    Using COBC False and FirsttickOfBar allows us to technically use both COBC false and true in the same code. For another example of this please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19387

                    Comment


                      #11
                      Thanks . . . I will work on it.

                      Lastly, if I wanted to use the moving average the 10 crossing above the 25 to go long ONLY if the ZScore is above 0 but not greater than 0.30 to go long BUT if the ZSCORE is greater 0.30 then ONLY use the moving average of 5 crossing above the 25 to long? Vice versa for for shorts?

                      In other words, use a different ma for each condition.

                      Thanks Patrick....that should wrap up this thread I think...
                      Last edited by birdog; 04-01-2014, 08:29 PM.

                      Comment


                        #12
                        Hello birdog,

                        Thank you for your post.

                        You would use if and else if, for example:
                        Code:
                        			if(CrossAbove(SMA(10), SMA(25), 1) && LogReturnsZScore(true, 2.0, 252).ZPlot[0] > 0 && LogReturnsZScore(true, 2.0, 252).ZPlot[0] < 0.30)
                        			{
                        				// Your Long method.
                        			}
                        			else if(CrossAbove(SMA(5), SMA(25), 1) && LogReturnsZScore(true, 2.0, 252).ZPlot[0] > 0.30)
                        			{
                        				// Your other Long method.
                        			}
                        			
                        			if(CrossBelow(SMA(10), SMA(25), 1) && LogReturnsZScore(true, 2.0, 252).ZPlot[0] < 0 && LogReturnsZScore(true, 2.0, 252).ZPlot[0] > -0.30)
                        			{
                        				// Your Short method.
                        			}
                        			else if(CrossBelow(SMA(5), SMA(25), 1) && LogReturnsZScore(true, 2.0, 252).ZPlot[0] < -0.30)
                        			{
                        				// Your other Short method.
                        			}

                        Comment


                          #13
                          Hi Patrick,

                          If the primary bars are Renko, Line Break, Daily, Hourly, etc (all manner of bar types and time frames), the Zscore you edited should be the same no matter what right? In other words, since the edited ZScore is set to use the Add(PeriodType.Day, 1); only it should be the same not matter what the Primary bar types or time frames are.

                          When I use Renko or other bar type, however, the number is different for the ZScore each time.

                          How can I make the Zscore be the same result no matter what Primary bar types or time frames are used? The ZScore I am looking for is always going to be the Daily Bars set to COBC=False (so the daily bars fluctuate throughout the day instead of waiting for the Daily bar to close to change).

                          Would appreciate addition input on this...I am also still playing with it too (if I get it before you post back I will let you know).

                          Comment


                            #14
                            Hello birdog,

                            Thank you for your response.

                            You need to set the DaysToLoad in the Data Series menu to a larger amount. Please right click in your chart and set DaysToLoad to a larger time frame such as 365 (standard for Daily bars).

                            Comment


                              #15
                              In the case of Renko, Range, Tick, or other type of chart, though, if I did that wouldn't it take forever to load if it tries to go back 365 full days (not to mention not needed for the primary bars)? I know it would be ok for daily bars if it was primary.

                              How can we have it load 365 days for daily bars in relation to using it for the ZScore ONLY but only load like 3-5 days of primary bars (like for Renko, Range, Tick, etc)?



                              Originally posted by NinjaTrader_PatrickH View Post
                              Hello birdog,

                              Thank you for your response.

                              You need to set the DaysToLoad in the Data Series menu to a larger amount. Please right click in your chart and set DaysToLoad to a larger time frame such as 365 (standard for Daily bars).

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              647 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              368 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              571 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X