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

Where to put it?

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

    Where to put it?

    For anyone out there that can help.

    I have been working on an indicator for a while that the NT team has been very helpful in helping me complete. Thanks so much to the team at NT as it is now working beautifully! Recently I found an idea that I would like to add to my indicator that will place a drawing (line, circle, dot, whatever) at a pivot point on the chart. These points are determined by a math equation and a difference in the HLC of the previous day and the open of the present day. Here is a sample of the formula;

    //PIVOT POINTS BASED ON MARKET CONDITIONS

    //For Decling market (today's open is lower than yesterday's open)

    //Upper Pivot Point = sum of yesterday's (((high + close)+(low*2))/2)-low)

    //declineupperpivot = (((PriorDayHLC(BarsArray[1]) .PriorHigh[0]) +(PriorDayHLC(BarsArray[1]) .PriorClose[0])) + (PriorDayOHLC(BarsArray[1]) .PriorLow[0] * 2) /2)) - (PriorDayOHLC(BarsArray[1]) .PriorLow[0];

    //Lower Pivot Point = sum of yesterday's (((high + close)+(low*2))/2)-high)

    //declinelowerpivot = (((PriorDayHLC(BarsArray[1]) .PriorHigh[0]) +(PriorDayHLC(BarsArray[1]) .PriorClose[0])) + (PriorDayOHLC(BarsArray[1]) .PriorLow[0] * 2) /2)) - (PriorDayOHLC(BarsArray[1]) .PriorHigh[0];

    Note that the BarsArray[1] is based on a period time set of 1440 minutes.

    My questions are thus;
    1. Does the use of PriorDay statements look correct?
    2. What part of this statement goes under "protected override void Initialize()" and what part goes under "protected override void OnBarUpdate()"?

    I truly appreciate any assistance provided.

    Best regards,

    Dolfan

    #2
    Hello Dolfan,

    Thanks for your post.

    Good to hear of your progress.

    The PriorDay statements, you have some that are PriorDayHLC and some that are PriorDayOHLC. I am familiar with PriorDayOHLC but not PriorDayHLC so unless you have PriorDayHLC as an indicator you would probably want to use PriorDayOHLC.

    All of the statements would be run in OnBarUpDate().
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul. I had seen HLC somewhere and since the math did not include the prior days opening, I thought OHLC not necessary. Will let you know how it proceeds.

      Best regards,

      Dolfan

      Comment


        #4
        OK, so this the most confusing part for me. I will need to place a drawing (yet to be determined) and a command to bring the math together with the drawing, right?

        declineupperpivot =(((PriorDayHLC ....as I understand it will call out a draw command. Currently my indicator has values in the region area hidden at the bottom of the coding that look like this

        #region Properties

        public int Period
        { get; set;}

        [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries R5
        {
        get { return Values[0]; }
        }

        ...that are called out (I assume) by these statements

        Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "R5")); //Values[0]

        in the "protected override void Initialize()" section.

        Given this format, may I assume that I will add a 'Values" line item and assign each of the new pivot lines to that value?

        Thanks so much for you assistance.

        Best regards,

        Dolfan

        Comment


          #5
          If you look inside the Pivots Indicator, you will see use of the HLC syntax. Might be where I got it from.

          Regards,

          Dolfan

          Comment


            #6
            Hello Dolfan,

            Thanks for your replies.

            As you add a plot, a reference will be made to Values[n] where n relates to added plots in the order they are added, so if R5 is the first plot then Values[0] is R5. Please see the example, under "Tips" in the helpguide here: http://ninjatrader.com/support/helpGuides/nt7/?add.htm it shows that plots in order are tied to Values.

            In your code then to assign/set a value to a plot, you can use the name of the plot (which is easier to read), for example:

            R5.Set(value to add); value to add would be the pivot value you calculate and the "set" on each OnBarUpdate().


            Here is a short version to tie all the pieces together:

            In the initialize()

            Add(new(Plot... "R5"); // first plot added = Values[0]

            in the OnBarUpdate()

            R5.Set(calculated pivot level to plot); // send the calculated value to the plot

            In the region properties:

            Browsable(false)]
            [XmlIgnore()]
            public DataSeries R5
            {
            get { return Values[0]; } // output the plot R5
            }
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              OK Paul, so this is where it gets complicated for me. The pivot points are based on immediate market conditions whereas today's open is compared to yesterday's open and if it is inclining, the upper and lower pivots are placed at X+. If the market is declining the pivot points are placed at X- and, if the market is flat the pivot points are placed at X. So essentially there are 3 initial checks made for market conditions before the math is performed. Since there are only 2 lines drawn, would this all be handled in the .Set's' section of OnBarUpdate or would I need to have 6 separate Plots in the initialize, 6 separate .Set's' in the OnBarUpdate and 6 separate values in the regions section?

              I would really like to simplify where I can and I am looking at the if,else statements to see if this is the correct way to go. Even if there are 6 different "sets" in all areas, I need to be able to apply the correct one based on market conditions.

              Thanks once again for your insight.

              Best regards,

              Dolfan
              Last edited by Dolfan; 08-12-2016, 02:21 AM.

              Comment


                #8
                Hello Dolfan,

                Thanks for your reply.

                I think you have the right idea.

                (Using R5 and R4 to represent your two plots)

                if (your market says positive)
                {
                R5.Set(value for new R5);
                R4.Set(value for new R4);
                }
                else if (your market says negative)
                {
                R5.Set(value for new R5);
                R4.Set(value for new R4);
                }
                else // to get here, assumption is market flat
                {
                R5.Set(value for new R5);
                R4.Set(value for new R4);
                }
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Geez! I thought I was getting close.

                  Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

                  Comment


                    #10
                    Hello Dolfan,

                    Thanks for your reply.

                    In the case of line 113, change PriorDayOHLC(BarsArray[1]) .PriorOpen to PriorDayOHLC(BarsArray[1]) .PriorOpen[0]

                    Change BarsArray[1].Open to Opens[1][0]

                    Reference: http://ninjatrader.com/support/helpG...nstruments.htm

                    It is difficult to advise on the rest with what you are showing.

                    I suspect it would be easier to take this offline. Please send your code to PlatFormSupport[at]NinjaTrader[dot]com Atten:Paul and a link to this thread.
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Have not been successful in the past sending emails through Ninja. I tried once again and it said it was sent successfully AFTER first sending an error. Please let me know if it has been received.

                      Best regards,

                      Dolfan

                      Comment


                        #12
                        Hello Dolfan,

                        Thanks for your post.

                        Your e-mail has been received and will be replied to later today.
                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by itrader46, Today, 09:04 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post itrader46  
                        Started by timmbbo, Today, 08:59 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post timmbbo
                        by timmbbo
                         
                        Started by bmartz, 03-12-2024, 06:12 AM
                        5 responses
                        33 views
                        0 likes
                        Last Post NinjaTrader_Zachary  
                        Started by Aviram Y, Today, 05:29 AM
                        4 responses
                        14 views
                        0 likes
                        Last Post Aviram Y  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X