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

Draw lines between session breaks

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

    Draw lines between session breaks

    I would like to create my own indicator similar to Pivots but I would like the lines to be drawn from session break (day) to session break (day). How would I do this and can it be done in the Indicator Wizard? Thanks!

    Best regards,

    Dolfan

    #2
    Hello,

    Thank you for the post.

    I wanted to check, similar to the pivots how?

    As in how the lines are drawn or how it actually calculates the data? Can you explain what specifically needs to be similar?

    The pivots indicator is a fairly complicated item in both how it displays its data and also how it collects its data. Depending on what you want similar, it may be easy or difficult.

    In any case, the indicator wizard would only be for initially adding Plots or Data to the indicator script, all indicators would need manually coded from that point on. You could utilize any of the code from the existing pivots indicator in your own files if you want as well.

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

    Comment


      #3
      Similar in that it draws daily but dissimilar in that I have my own formulas to determine locations on the charts and the Pivots Indicator does not draw from session line to session line, I would like for this to happen.

      I found on the forum a Camarillo strategy that has similar indicator lines that I believe I can work with. Again, I have my own ideas about where the lines go (my formulas) but the basis structure seems to be there. You can take a look for yourself if you like and tell me what you think.

      Best regards,

      Dolfan

      Comment


        #4
        Hello,

        Thank you for the reply.

        In this case if you just want to use custom formulas and then draw them session to session, you could use the FirstBarOfSession property to determine when a new session has begun to draw lines. http://ninjatrader.com/support/helpG...ghtsub=session

        This could be used to set a starting point for the line. Once the session has Elapsed and FirstBarOfSession is called again, you could start a new line.

        In this case, I don't believe you would need anything out of the pivots at all for what I mentioned above. Instead you would only need to create the math you need in the script and Plot it using a Line.

        If you instead wanted to use the Pivots for how it requests data, there would really be no better example than the pivots indicator its self and its source code. There would be no getting around the amount of code it uses and would be a manually coded item like all indicators are.

        If you also want the lines to look similar to the Pivots in the sense that the lines only occupy part of the screen, in that case you would need to use the Plot override as the pivots does to display the data.


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

        Comment


          #5
          Thanks Jesse. It looks like the hard way for me. The Camarillo code is what I am starting with since it seems to have the right structure for me. The thing I do not like about Camarillo and Pivots is that it takes data only from yesterday's trading activity and since there can be volatility some days and a flat market on others, this seems to be an unreliable way of predicting a trading range. My goal is to plot lines that will be indicative of trading activity over the past 2 weeks (or more if necessary). I feel like this data will be more reliable long term.

          My spreadsheet formulas take into account daily averages for a week(s). What do you feel is the best way to capture this data in Ninja? Here is some syntax from Camarillo;

          double high = PriorDayOHLC().PriorHigh[0];
          double low = PriorDayOHLC().PriorLow[0];
          double close = PriorDayOHLC().PriorClose[0];
          double range = high - low;

          In looking at the code I can see how it is used to draw data from yesterday's trading. Would it be better to create repeating lines of code going back with Prior (High/Low/Close)[1,2,3,4,...10] ? Or can I use a week bar like I tried to do below but was rejected when compiling?

          double week1ATR = PriorWeekOHLC().PriorAverage[0];

          Keep in mind that when I say better, I mean accurate data as well as ease of programming. The data pulled from those lines should be an average change for all 5 days of a week. For example if the price change Monday through Friday one week was $43, 44, 45, 46 & 47, then I would expect the average change for the week bar to return at $45. I don't want the data to return what the average change for the week overall.

          Your thoughts?

          Best regards,

          Dolfan

          Comment


            #6
            Hello,

            Could you provide a link for the specific item you are referring to? I had searched for the term Camarillo in the sharing section but nothing came up. Perhaps the indicator was not mentioned in the strategies description.

            If the script is what you would like to use, you can as a base for what you want to create.

            You noted that the script is using PriorDayOHL, this has a BarsAgo index which you also noted. You may be able to replicate the already existing logic to include a number of days ago instead of one.

            It sounds like you have the correct idea if you wanted to include a weeks worth of data to match your calculations in excel, but PriorWeekOHLC is not an indicator. You could still use the PriorDayOHLC but you would supply a BarsAgo value to get other days values:

            Code:
              PriorDayOHLC().PriorHigh[B][1];[/B]
            If you are able to use the existing logic and make some sort of change that can use a Bars ago, you may be able to make that indicator work in the way you want. It is hard to say what might need changed without seeing it.

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

            Comment


              #7
              Search for March2013SC.zip

              Comment


                #8
                I think this should work but the line values the indicator is placing do not coincide with what my spreadsheet has. How do I get the value that this line returns printed to the output window, or where ever? Thanks!

                double high = (PriorDayOHLC() .PriorHigh[0] + PriorDayOHLC() .PriorHigh[1] +PriorDayOHLC() .PriorHigh[2] +PriorDayOHLC() .PriorHigh[3] +PriorDayOHLC() .PriorHigh[4] +PriorDayOHLC() .PriorHigh[5] +PriorDayOHLC() .PriorHigh[6] +PriorDayOHLC() .PriorHigh[7] +PriorDayOHLC() .PriorHigh[8] +PriorDayOHLC() .PriorHigh[9]) /10;

                Best regards,

                Dolfan

                Comment


                  #9
                  Jesse,

                  When I started my spreadsheets some months back I was informed that I should be using 1440 minute bars instead of day bars. How would I change this code to use 1440 minute bars and do you think that would help with my inconsistent numbers? Note that the spreadsheet data comes from 1440 minute bars and this code is day bars. Thanks!

                  Best regards,

                  Dolfan

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    Where is the Print you are trying to get the value from? Generally if you want to use a value you are currently Printing, likely you could just use the same variable or equation you had used in the print in other places. If you can provide the Print, I could likely tell you what the variable is or what you are using in the print.

                    As far as values matching up with the spreadsheet, all of the math is going to be up to you and your personal goals. I really couldn't say if the 1440 minute bars is the solution. If the existing calculations already use 1440 minute bars, likely you would need to make the platform match or also use the same data to reach the same result mathematically.


                    for adding a series, there are a few documents you should review to understand the logic needed when adding a secondary series. First multi bar scripts, this document outlines how the platform will process the data: http://ninjatrader.com/support/helpG...nstruments.htm

                    Also the Add method, this page lists the options you have available and sample syntax: http://ninjatrader.com/support/helpG...ghlightsub=add

                    To add a 1440 minute series, you could use:

                    Code:
                    protected override void Initialize()
                    {
                        Add(PeriodType.Minute, 1440);
                    }
                    If you will be using the PriorDayOHLC with the 1440 minute series, you would also need to use the optional overload for PriorDayOHLC to specify that it uses that series.

                    It would look like this:
                    Code:
                    PriorDayOHLC[B](Closes[1])[/B].PriorHigh[0]
                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks Jesse. I will look at modifying to get the 1440 bar data.

                      For the print function, I have been unsuccessful to date using this function. For the "double high" parameter that I set up below, I would like for it to display the value that is returned for that equation. Where and how will that syntax appear? Thanks!

                      Best regards,

                      Dolfan

                      Comment


                        #12
                        Hello,

                        If you are trying to Display the following or Print it:

                        double high = (PriorDayOHLC() .PriorHigh[0] + PriorDayOHLC() .PriorHigh[1] +PriorDayOHLC() .PriorHigh[2] +PriorDayOHLC() .PriorHigh[3] +PriorDayOHLC() .PriorHigh[4] +PriorDayOHLC() .PriorHigh[5] +PriorDayOHLC() .PriorHigh[6] +PriorDayOHLC() .PriorHigh[7] +PriorDayOHLC() .PriorHigh[8] +PriorDayOHLC() .PriorHigh[9]) /10;


                        You could use the Variable name or high, you may want to rename this variable to not be confused with the already existing High series.


                        Code:
                        Print(high); //will Print the value to the Output window for you to see.
                        or you can use this value in any of the drawing tools because it is a double:

                        Code:
                        double high = (PriorDayOHLC() .PriorHigh[0] + PriorDayOHLC() .PriorHigh[1] +PriorDayOHLC() .PriorHigh[2] +PriorDayOHLC() .PriorHigh[3] +PriorDayOHLC() .PriorHigh[4] +PriorDayOHLC() .PriorHigh[5] +PriorDayOHLC() .PriorHigh[6] +PriorDayOHLC() .PriorHigh[7] +PriorDayOHLC() .PriorHigh[8] +PriorDayOHLC() .PriorHigh[9]) /10;
                        
                        DrawLine("MyLine", 10, high, 0, high, Color.Blue);
                        I look forward to being of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          OK, I have a fundamental problem with what is calculating here. I went to a daily OHLC chart and added all the highs and divided by 10, then the lows and divided by 10, subtracted the low from the high and came up with this...

                          Average high is 46.88
                          Average low is 45.52
                          Range is 1.36

                          I added this syntax to my code;


                          Print(high); //will Print the value of the high to the Output window for you to see.
                          Print(low); //will Print the value of the low to the Output window for you to see.
                          Print(range); //will Print the value of the range to the Output window for you to see.
                          DrawLine("MyLine1", 10, high, 0, high, Color.Blue);
                          DrawLine("MyLine2", 10, low, 0, low, Color.Blue);

                          ...and I get lines that are drawn at 46.13 and 44.55 as can be seen here. The range is 1.58. http://screencast.com/t/uwVgJJJPb

                          The math seems more than simple enough. What is it that I am missing?

                          Dolfan

                          Comment


                            #14
                            "If you will be using the PriorDayOHLC with the 1440 minute series, you would also need to use the optional overload for PriorDayOHLC to specify that it uses that series.

                            It would look like this:
                            Code:
                            PriorDayOHLC(Closes[1]).PriorHigh[0] "

                            Jesse,

                            You have been very helpful so far, thank you very much. Is this (Closes [1]) statement to be included in the middle of each PriotDayOHLC.PriorHigh[0] thru PriorDayOHLC.PriorHigh[9] statement?

                            Just for my own amusement, how does that call the initialize statement..
                            Add(PeriodType.Minute, 1440);

                            Comment


                              #15
                              Jesse,

                              I have been trying to understand how my lines are being drawn and in reviewing the charts I notice that Sunday is a day that data is pulled from. http://screencast.com/t/rR8gorpcKTs
                              I enter data in my spreadsheets from Monday thru Friday only, when I believe, the pertinent data for support and resistance zones are generated. Is it possible in this syntax...

                              double high = (PriorDayOHLC() .PriorHigh[0] + PriorDayOHLC() .PriorHigh[1] +PriorDayOHLC() .PriorHigh[2] +PriorDayOHLC() .PriorHigh[3] +PriorDayOHLC() .PriorHigh[4] +PriorDayOHLC() .PriorHigh[5] +PriorDayOHLC() .PriorHigh[6] +PriorDayOHLC() .PriorHigh[7] +PriorDayOHLC() .PriorHigh[8] +PriorDayOHLC() .PriorHigh[9]) /10;

                              ...can be altered to only pull data from Monday thru Friday or do I have to enter more complex data elsewhere?

                              Thanks!

                              Best regards,

                              Dolfan

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X