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

Multiple TimeFrame Indicator

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

    Multiple TimeFrame Indicator

    Okay I have been working on an indicator for a few hours today and I can't figure it out.

    I have a 5 minute chart with data.

    In the indicator I add daily data in the Initialize() section
    Add (PeriodType.Day, 1);

    So I want to take the ATR and StdDev of a defined user variable called "numPeriods" off the daily data and use it for calculations to plot an indicator on the 5 minute.

    I have no idea how to get it to work. I think I am making it too difficult. I have tried all kinds of nesting combinations with BarsInProgress == 0 and 1 and CurrentBars[0] and [1] and I can't get it to work.

    It seems like it should be simple, can anyone help? I have calculate on bar close to true so it calculates and plots on the 5 minute at the end of the bar.

    Thanks

    #2
    dbntina, what outcome are you then seeing? An error, no plot / print return or just an unexpected outcome? You would process in BarsInProgress 0 the indicators running on the BarsArray[1] (the daily input) then. How many days of data are you loading up for this task?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I am loading 200 days worth of data and using a period value of 30 and it is plotting so it has enough data.

      I am getting an unexpected outcome. It is plotting very small ATR and SD values so it's not getting the correct values from the daily.

      I don't know how to pass the ATR and SD of the calculated values in the section of BarsInProgress == 1 to the section where I plot in BarsInProgress == 0.

      Comment


        #4
        Thanks, as an example you can look into for example this snippet, it takes one ATR off the mid point session value calculated from the primary series - so we're not processing anything in the added daily series, but just access the bars data for feeding it into our ATR method -

        if (BarsInProgress != 0 || CurrentBars[0] < 0 || CurrentBars[1] < 0) return;

        Plot0.Set(0.5 * (PriorDayOHLC().PriorLow[0] + PriorDayOHLC().PriorHigh[0]) - ATR(BarsArray[1], 30)[0]);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Ok, so I was trying to run the calculations off the daily every time a daily bar completed BarsInProgress == 1 and then pass it to BarsInProgress == 0 to plot.

          It sounds like I don't want to do that, I want to recalculate the ATR and SD every bar on the 5 min and use that value? Seems like I would be wasting resources doing that?

          Thanks Bertrand I will try that. I guess the problem I am having is there isn't a way to save calculations when a daily bar completes and use that value to plot on the 5 minute?

          David

          Comment


            #6
            Bertrand,

            I am thinking that my syntax for calculating ATR might be wrong.

            Can I do it this way?

            Add a new dataseries called DailyRange
            DailyRange.Set(Highs[1][0] - Lows[1][0]);
            ATR.Set(ATR(DailyRange,numPeriods)[0]);
            SD.Set(StdDev(DailyRange,numPeriods)[0]);

            It's not getting the correct values for some reason?

            Comment


              #7
              Hi David, you can however that would not be the ATR of the daily prices then, but of the daily ranges ... which would make sense to see a lower variation in the values then, since the range is much smaller than the absolute price level.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Correct I am trying to get the daily true range not including gaps.

                For some reason it's not plotting correctly (I have an indicator that is hard coded with the "correct" answer to compare to and it isn't even close.

                It's as if its using 30 5 minute bars for the calculation or something?

                Comment


                  #9
                  Ok, if that is intended great. You work with the DailyRange series in BarsInProgress == 0, the smaller 5 min chart? That's what the series per default would be synched to, you can however sync it as well to the daily interval.

                  Note: In NinjaTrader 8 It is no longer needed to use an indicator to sync a secondary series. This can be done directly from the Series&lt;T&gt; (https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?seriest.htm) constructor. This post is left for historical purposes. Series objects are useful for
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    IF I start with daily then I won't getting plotting on the 5Min chart which is what I need correct?

                    Comment


                      #11
                      Okay,

                      I think I found the problem, but I don't know why?

                      In the onbar update section I am giving it a choice to use the user entered SD and ATR values and then plot off of those or use the calculated SD and ATR values to plot off the calculated values. So I entered the hard coded values in the calculated section to test the plots and they are plotting differently than the user entered values? How I have no idea. I even checked the output window and the values are identical for both plots?

                      5 min is primary daily is added in Initialize section

                      if (BarsInProgress != 0 || CurrentBars[1] <= (numPeriods + 2)) return;

                      if (useCalcData == true)
                      {
                      lines of code set variables
                      }
                      else
                      {
                      lines of code set variables
                      }
                      set plot values off of calculated variables

                      Comment


                        #12
                        Would you mind sending me the script to support at ninjatrader dot com? We would then give it a run here and let you know our thoughts.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Sure where to email it?

                          Comment


                            #14
                            Please just to send to

                            support at ninjatrader dot com

                            Or attach via the Help > Mail to Support process inside NT to us.
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by fx.practic, 10-15-2013, 12:53 AM
                            5 responses
                            5,403 views
                            0 likes
                            Last Post Bidder
                            by Bidder
                             
                            Started by Shai Samuel, 07-02-2022, 02:46 PM
                            4 responses
                            94 views
                            0 likes
                            Last Post Bidder
                            by Bidder
                             
                            Started by DJ888, Yesterday, 10:57 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by MacDad, 02-25-2024, 11:48 PM
                            7 responses
                            158 views
                            0 likes
                            Last Post loganjarosz123  
                            Started by Belfortbucks, Yesterday, 09:29 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post Belfortbucks  
                            Working...
                            X