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

Multi-time frame beginner

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

    Multi-time frame beginner

    I have a 1 min CL chart. In my indicator to get started in multi-time frame I have added:

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Add(PeriodType.Minute, 5);
    }

    The 5 min bars don't show up after installing my indicator. What am I missing?

    #2
    Hello,

    Thank you for the question.

    The visual representation of the added series should not show up when added from an indicator. Only the addition Data will be able to be accessed by the indicator.

    The Chart its self should not change when you add additional data from script, that indicator will then have secondary series in which you can access the data for. This also adds BarsInProgress indexes, this means that OnBarUpdate will get called for each series and you can filter logic based on the BarsInProgress.

    To check that the series was added, you could add a Print into OnBarUpdate like the following:

    Print(BarsInProgress);

    This should print 0 and 1 values, a Single series script would only print 0.

    If you are instead just trying to add a visual set of bars to the chart, you would need to use the DataSeries window to manually add another series to the chart.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the help,I have another question:

      I would like to program a 3 day pivot. In order to do this I thought I would use the Add method to my chart to install daily data, then do average high, low, etc of daily data to get my 3 day pivot. But I find that NinjaScript does not recognize Daily as a period type.

      Any ideas?

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes you are correct in thinking you need to add daily data for the indicator to access that data. An indicator can only access the Primary input of the chart which would be what you set as its Input Series. After that any additional data you would need to add additional series using code.

        To add a Day series, you need to use Day instead of Daily. You can find all of the options by either using the Help Guide and searching for PeriodType which results in this link: http://ninjatrader.com/support/helpG...sub=PeriodType

        Or in the NinjaScript editor, after typing the word PeriodType and pressing period . you should see a drop down list of all of the available PeriodTypes.

        You can find more information about Multi series scripts in this helpguide article: http://ninjatrader.com/support/helpG...nstruments.htm

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Under Initialize when I type: Add(PeriodType.Day) I get the following error message:

          Argument "1" cannot convert from NinjaTrader Data PeriodType' to NinjaTrader Gui Chart Line'

          Frustrating!

          Comment


            #6
            Hello,

            This would not be the correct syntax to add a series, you have not defined the amount of days needed so the first overload set of Add is being used.

            Add has multiple functions so you would need to use the correct number of paramers for the task needed. In this case you can use the following to add 1 day series:

            Code:
            Add(PeriodType.Day, 1);
            You can find more information about NinjaScript methods like Add in the helpguide: http://ninjatrader.com/support/helpG...ghlightsub=add

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the help. I am getting there slowly. One more question:
              I want to find the highest price in the last three 45 min bars.

              highest = MAX(High, period) [2];

              What is meant by "period"?

              Comment


                #8
                Hello,

                Thank you for the reply.

                The Period in this case would be the period of time that is used. if you wanted to search 3 bars, you could use 3 as the period to include 3 bars of data.

                The [2] you have, would be a BarsAgo which is similar to the period but would denote the signals of this indicator for each bar. This means if you wanted to know what the Max was of 2 bars ago, a [2] would be used. For the current value a [0] can be used.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Thanks, I didn't phrase my question right:

                  I would like to find the highest high (value) for Bars[1],[2],& [3] without having to use a For loop. Is there any way to do this?

                  The sentence:

                  if(High[1] > High[2] || High[3]) {highest = High[1]}; does not compile.

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    The answer would be to use what you had already provided or the MAX to check a period of time for the Maximum value.

                    I described in my last message on the period and barsago used in MAX, you would need to use a 3 Period if you want to look back 3 bars and if you wanted the CurrentBars value of the MAX you would use [0] bars ago. Here is a example of MAX used with a 3 period:

                    highest = MAX(High, 3) [0];

                    This would get the most recent MAX value from the High series for a period of 3 bars.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks. My problem is that I do not want to include Bar[0] in the calculation. I want to get the highest high of Bar[1], Bar[2] and Bar [3].

                      Comment


                        #12
                        to explain further what I am trying to do, I am trying to make an indicator for a three day pivot, the formula in this case highest high of three days ago plus lowest low of three days ago plus yesterday's close divided by three.

                        Comment


                          #13
                          Hello,

                          Again MAX would be the suggested way to get the Highest Value of X period.

                          If you do not want to include 0 bars ago, you would need to use 1 bars ago for the BarsAgo in MAX. Additionally this would depend on what you mean by not including 0 bars ago.

                          If the indicator is running on CalculateOnBarClose = true, you are already not including the Building/ current or right most bar in the set because it is not closed yet. If you are using CalculateOnBarClose = false then you are including the right most bar in the set.

                          Based on your initial post showing CalculateOnBarClose = true, the default 0 BarsAgo should be what you are looking for as it would not include the current or building bar. 0 bars ago would be one bar from the right of the chart. If that is what you had intended, it should already be doing that. If instead you wanted 1 bars ago or two bars from the right of the chart, you could use [1] for the BarsAgo on MAX.

                          To better see the values included, you could try using Dots to mark the last 3 bars to see where the dots are plotted:

                          if(CurrentBar < 3) return;
                          DrawDot("zeroBarsAgo", true, 0, Close[0], Color.Red);
                          DrawDot("oneBarsAgo", true, 1, Close[1], Color.Red);
                          DrawDot("twoBarsAgo", true, 2, Close[2], Color.Red);
                          DrawDot("threeBarsAgo", true, 3, Close[3], Color.Red);

                          You should see 4 dots and then the building bar, if you are on COBC false you should see 4 dots one being on the building bar.

                          Depending on where you want the Period to start and end, these dots could help identify which bars would be included for you to adjust the BarsAgo to what is needed.

                          I look forward to being of further assistance.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            Your dot test got me on the right track. MAX(High)[0] was the answer. The program is now drawing a blue line at the three day pivot, and by using multi-charts works on all time frames.

                            One last question: I would like to add some text at the right end of the line and have the price show there in the price column. could you give me a hint how to approach this?

                            Comment


                              #15
                              Hello,

                              Glad to hear the dots were able to help illustrate the data.

                              For drawing text specifically, you can use DrawText: http://ninjatrader.com/support/helpG...htsub=drawtext

                              This is a general text drawing tool which uses a bar and price to place the text. If you need further control over text there is also DrawTextFixed: http://ninjatrader.com/support/helpG...=drawtextfixed

                              There are also other more complex ways of drawing text if you need but in general these two items cover a broad range of uses.

                              I look forward to being of further assistance.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rtwave, Today, 01:49 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post rtwave
                              by rtwave
                               
                              Started by papaoutai, Today, 08:56 AM
                              0 responses
                              22 views
                              0 likes
                              Last Post papaoutai  
                              Started by jdspwe, Today, 05:22 AM
                              0 responses
                              13 views
                              0 likes
                              Last Post jdspwe
                              by jdspwe
                               
                              Started by JeremuFemstu, Today, 04:49 AM
                              0 responses
                              16 views
                              0 likes
                              Last Post JeremuFemstu  
                              Started by pjsmith, Today, 04:11 AM
                              1 response
                              21 views
                              0 likes
                              Last Post Green Lobster CBD  
                              Working...
                              X