Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Marker Example Code

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

    Price Marker Example Code

    Please provide example code to do the following:
    • Add a new Price Marker on a chart at a specific (dynamically changeable) value
    • Extend a horizontal line from the head of the arrow of the Price Marker a given (dynamically changeable) length across the chart, possibly the full width
    • Change the line style (color, solid/dashed/invisible, width, etc) at any time
    • Change the Price Marker style/format (color, shape, etc) at any time
    • Change the Price Marker content/format (color, font, text, etc) at any time
    There have been many requests/discussions in the Forum on Price Markers. The above is one simple example of what is needed. Can any/all this be done and, if so, how? Please provide example code that showcases the maximum flexibility of this approach, inasmuch as any/all is achievable in RC1.

    Thanks.
    Last edited by jeronymite; 09-23-2016, 04:16 AM.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Thank you for your post.

    Below I have addressed each of your items.
    1. To set a Price Market at a specific level use a Plot and set the plot's value to a user defined input parameter, such as a double.
    2. Set an int as a user defined input parameter. Perform a check before setting your plot, this check will compare the CurrentBar to Count minus the int. If it is less than it returns and does not plot.
    3. This would easily be controlled by the Plot parameters in the Indicator parameters.
    4. The "content" would be controlled by Chart Properties.

    Attached is a basic indicator that you can build that allows for the items you detail.
    I highly recommend reviewing Indicators and Chart Properties at the following links:
    Attached Files

    Comment


      #3
      Price Marker Example Code

      Thanks, Patrick.

      Here is one of the relevant previous posts on this subject: http://ninjatrader.com/support/forum...ad.php?t=73907

      In particular, how does one create a coloured price marker that has an invisible line (or no line).

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Thank you, jeronymite.

        I will add your vote for the feature request SFT-335.

        Comment


          #5
          Price Marker Example Code

          Thanks, Patrick.

          In the meantime, please advise how to create a coloured price marker that has an invisible line or a line of zero length or no line at all.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            Hi Jeronymite,

            I have a request from NT, but I may be able to help you at least temporarily and if you are code literate.

            I have made my V2 price line which shows the bar timer through a custom made price marker. The price marker is as close a replica I can get for the standard NT price marker.

            However it will not plot within the chart scale. I made it to plot anywhere on the chart I want. The price line code will give you an example of creating variable length lines etc.

            The price marker is in the Addon 'Sim22_DrawingUtilities' under the 'DrawPriceMarker' method. It is not a drawing tool as such so this can only be accessed through OnRender.

            It's still in beta, although I have ironed out all the bugs, I make no guarantee. So here it is for your perusal.

            For NT staff: Would you please be so kind as to tell me by what relationship is the price marker height to the text size? I am using:

            price marker height = 1.26 * label size.

            Though it is not quite right. Are you using a multiplication or addition to get the price marker height? Or better still reveal the price marker code????

            Thank you.
            Attached Files
            Last edited by Sim22; 09-29-2016, 03:23 AM.

            Comment


              #7
              Price Marker Example Code

              Thanks, Sim22 -- very much appreciate your insights.

              I have written lots of code and so look forward to seeing your implementation. Apologies if I have missed it, but is there a link to your code somewhere?

              Currently, I format "standard" chart price markers, created with AddPlot, with short leading text. However, I want to create price markers that do not have a line (or other graphical plot) associated with them and the best I can get using AddPlot is a horizontal line of 1 bar's length between the two most recent bars -- I cannot eliminate the line altogether.

              Picture attached. Three price markers with horizontal lines, and three with (ideally no line, but) a 1-bar's width line.

              Thanks.
              Attached Files
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment


                #8
                Originally posted by jeronymite View Post
                Thanks, Patrick.

                In the meantime, please advise how to create a coloured price marker that has an invisible line or a line of zero length or no line at all.

                Thanks.
                This would be what I provided before. I have attached the example to this post as well.
                Attached Files

                Comment


                  #9
                  Originally posted by Sim22 View Post
                  Would you please be so kind as to tell me by what relationship is the price marker height to the text size? I am using:

                  price marker height = 1.26 * label size.

                  Though it is not quite right. Are you using a multiplication or addition to get the price marker height? Or better still reveal the price marker code????

                  Thank you.
                  This would be code that is proprietary.

                  Comment


                    #10
                    Price Marker Example Code

                    Hi Patrick. Forgive me if I am misunderstanding your code. It seems that the value of the price marker will be updated only when the CurrentBar increments. If that is so, that is not what I am trying to do. The price marker needs to update on every tick.

                    For example, if the price marker is for the current Ask price, it must update every time the Ask price changes, even within a single bar. The code you have provided would only update on a new bar.



                    So, if I may restate what I'm trying to do:
                    • Create a price marker that updates every tick
                    • The price marker has a zero length line (or no line) associated with it
                    Please let me know if I have missed something obvious. If not, please let me know how to do this.

                    Thanks for your kind assistance.
                    Multi-Dimensional Managed Trading
                    jeronymite
                    NinjaTrader Ecosystem Vendor - Mizpah Software

                    Comment


                      #11
                      Doh.......

                      Sorry, yes I thought I had forgotten to upload it.

                      Jeronymite,

                      the trick to not display a line is to use OnRender.

                      PHP Code:
                       
                      protected override void OnRender(ChartControl chartControlChartScale chartScale)
                      {
                       
                            if (
                      Bars == null || chartControl == null || Bars.Instrument == null || !IsVisible)
                            {
                                 return;
                            }            
                                  
                      //base.OnRender(chartControl, chartScale);
                       

                      This will just display the NT price marker, assuming you set a value within OnBarUpdate.

                      Uncommenting the base.OnRender....... will allow your AddPlots to show in their completeness.

                      To update every tick just set Calculate to Calculate.OnEachTick.

                      Hope that helps.
                      Attached Files

                      Comment


                        #12
                        Originally posted by NinjaTrader_PatrickH View Post
                        This would be code that is proprietary.
                        Of course, one cannot share the family secrets. Heaven forbid I would make a custom price marker

                        Comment


                          #13
                          Originally posted by jeronymite View Post
                          Hi Patrick. Forgive me if I am misunderstanding your code. It seems that the value of the price marker will be updated only when the CurrentBar increments. If that is so, that is not what I am trying to do. The price marker needs to update on every tick.

                          For example, if the price marker is for the current Ask price, it must update every time the Ask price changes, even within a single bar. The code you have provided would only update on a new bar.



                          So, if I may restate what I'm trying to do:
                          • Create a price marker that updates every tick
                          • The price marker has a zero length line (or no line) associated with it
                          Please let me know if I have missed something obvious. If not, please let me know how to do this.

                          Thanks for your kind assistance.
                          Are you looking for a developer to help you make this?

                          If you are a programmer, are you aware of Calculate? - http://ninjatrader.com/support/helpG.../calculate.htm
                          Are you aware of setting values to plots? - http://ninjatrader.com/support/helpG...us/addplot.htm

                          Comment


                            #14
                            Price Marker Example Code

                            Patrick, Using exactly your example code, the following behaviour occurs:
                            • The minimum selectable length of the line produced is 1
                            • The line produced grows in length as each new bar is added
                            • Note that if the value of the plot is dynamic, not fixed as in your example, a plot trace is drawn instead of a horizontal line
                            • The line "emits" from the first bar and not the price marker, hence there is a gap between the price marker and the start of the line
                            Allow me to once again state what I am after:
                            • A price marker with NO line (or zero length line) ... OR optionally ...
                            • A price marker with a specifiable fixed length horizontal line (it does not change in length as bars are generated)
                            • A line of fixed length that emits from the price marker, not the first bar
                            The zero length line option is essentially the same as the "standard" black price marker on a chart, but formatted to the colour of my choice. The positive length line option is essentially the Plot with an Hline but with the length of the line truncated at a specified length from the price marker.

                            The problem seems to stem from how the line and price marker formatting are apparently linked to the formatting of the Plot as a whole. It would seem obvious that to hide the line altogether one could change the colour of the Plot to Transparent. Unfortunately, if one does this on the Plot itself or on PlotBrushes[0], the price marker also disappears. Doing this on PlotBrushes[1] and above still leaves a single bar's width line of the Plot Brush colour.

                            It seems there needs to be a way to specify the colour of the price marker separately from and independently of the colour of the plot object.

                            In any case, your advice on how to do what I am requesting would be most appreciated.

                            Thanks.
                            Last edited by jeronymite; 10-03-2016, 02:10 AM. Reason: Additional explanation
                            Multi-Dimensional Managed Trading
                            jeronymite
                            NinjaTrader Ecosystem Vendor - Mizpah Software

                            Comment


                              #15
                              No means to do so outside of the example provided in my reply.

                              This feature request is tracked under SFT-335.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by techgetgame, Yesterday, 11:42 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post techgetgame  
                              Started by sephichapdson, Yesterday, 11:36 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post sephichapdson  
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,613 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Yesterday, 05:56 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              20 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Working...
                              X