Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator draw line from active bar?

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

    Indicator draw line from active bar?

    Hi.

    In your system-provided PriceLine.cs Indicator; you have
    some very nice code which draws some horizontal lines from a
    configurable percentage left of the right chart margin, to the
    chart's right margin. It's great example code found
    in the override
    void OnRender(ChartControl, ChartScale)

    I WOULD LIKE to draw that horizontal line starting at the x position
    of the "currently forming bar", and extending to the right margin,
    instead of a fixed length horizontal line.

    How could I do that, instead, in my OnRender(...)?

    Thanks! hyper



    #2
    Hello Hyper,

    Thanks for your post.

    Try this:

    Code:
    float startX    = ChartControl.GetXByBarIndex(ChartBars, BarsArray[0].Count-1);
    Click image for larger version

Name:	NinjaTrader_2020-12-23_12-39-55.png
Views:	751
Size:	24.5 KB
ID:	1133649

    To get more acquainted with SharpDX rendering, please see the Help Guide article below, and please see the SampleCustomRender indicator that comes with NinjaTrader.

    https://ninjatrader.com/support/help..._rendering.htm

    Happy Holidays!
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you, Jim !; good idea and suggestion, which I'll try asap !
      Happy Holidays to All ! and stay safe; the Vaccine Cavalry is on the way...
      hyper

      Comment


        #4
        I AM IMPRESSED ! IT WORKS. Thank you, Jim.

        Code:
        //startX = ChartControl.GetXByBarIndex(ChartBars, BarsArray[0].Count-1);
        startX = (float)ChartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex);
        I used the second of the 2 forms above; which I believe are actually equivalent.

        Thank you so much !!
        hyperscalper

        Comment


          #5
          Hello hyperscalper,

          They are not exactly identical, BarsArray[0].Count-1 would be the developing bar, and ChartBars.ToIndex would be the right most visible bar.

          Let us know if there is anything else we can do to help.
          JimNinjaTrader Customer Service

          Comment


            #6
            THANKS so much for that; it's a crucial distinction !! ; so I'll
            correct my code.
            Really appreciate the timely support !!!
            Happy Holidays!
            hyper

            Comment


              #7
              INSTEAD OF A NEW THREAD, can I trouble you
              for one more possibility.

              Given X, Y relative on a Chart Canvas; can I map to
              global display Screen Coordinates
              by any convenient function?

              THANKS!
              hyper

              Comment


                #8
                Originally posted by Hyper View Post
                Given X, Y relative on a Chart Canvas; can I map to global display Screen Coordinates by any convenient function?
                Code:
                //Variables
                Chart curChart;
                Get the current Chart using a dispatcher.. in State.DataLoaded or after
                Code:
                ChartControl.Dispatcher.InvokeAsync((Action)(() => { curChart = Window.GetWindow(this.ChartControl.Parent) as Chart; }));
                From there you should be able to grab the absolute screen coordinates of WindowStartupLocation and perform whatever calculations you need..
                Code:
                curChart.Top
                curChart.Left


                Be Safe and Merry Christmas!



                -=Edge=-
                NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                Comment


                  #9
                  Hi. I think the answer to my question of mapping to device coordinates is answered by

                  the overloads for ConvertToVerticalPixels and ConvertToHorizontalPixels
                  which I understand as device coordinates.

                  I've really had to work hard to figure out how to implement this
                  "Auto Drag Left" function; and continue to wish the Platform could implement
                  this functionality as a standard option. The constant "sliding" of the chart
                  to the left on EACH new bar; is a big waste of I/O to remote servers;
                  something I've tried to explain with only limited success.

                  My Indicator implementation is forced to use Win32 API calls in order
                  to "drag" the chart leftward. But PLATFORM DEVELOPMENT could
                  simply set the position of the currently forming bar to the left; with a
                  completely clean implementation; OR expose that ability to Indicator
                  developers.

                  hyperscalper

                  Comment


                    #10
                    Hello hyperscalper,

                    I'm not sure I follow entirely.

                    Do you mean you want the developing bar to be always on the left so there is less redrawn and so performance is better when viewing remotely? Could you describe your "Auto Drag Left" idea further as well as it's usefulness? (Screenshots can help) I would approach this using SendKeys and having the right cursor key invoked. You could also decrease the size of the chart so less bars are visible. I'm not sure what the pain point is that you are trying to overcome.

                    Did you request this previously and have you gotten an SFT tracking ID for the request? (We receive numerous requests and cannot guarantee fulfillment, but we would like to have the idea tracked if it is not already.)

                    We look forward to assisting.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hi. Thanks for considering this. It is an "optimization" for those of
                      us who use Dedicated Servers or even Virtual Private Servers to
                      host NinjaTrader; but who use Remote Desktop for communications.

                      In my case, I benefit from seeing the Market price with the minimum
                      possible delay; which means the minimum possible ongoing I/O
                      to update charts. I use 1 Second interval charts; so there is a need
                      to "slide" the entire Chart image to the left, every single second.

                      However, a very simple Chart optimization would formulate a rule, such as:
                      When the current bar is within X% ( maybe 5% of chart width) from
                      the Right Margin, then a single "move left" (similar to a Mouse
                      Drag Left) would be done, to position the chart Left in a single
                      move, to maybe Y% ( maybe 20% from right margin) in a single
                      "jump". X% and Y% would be configurable parameters, where
                      Y% is always to the left of the X% trigger distance from margin.

                      This would work for Tick charts; as well as Interval charts, so that
                      repaint I/O "bursting" would be needed just once
                      on the Auto Scroll Left action; but then
                      essentially only the currently forming bar and perhaps axis
                      updates would be required; but the vast area of the Chart surface
                      (in many case, not all cases, rescaling being an exception)
                      remains a "static image" and thus the remote viewing RDP protocol
                      would have no need to re-transmit updates to those pixels.

                      This will result in probably 95% elimination of unnecessary I/O
                      in most cases where most of the Chart panel(s) data is not
                      required to update, during the period between the "scroll left" and the
                      eventual need to "jump scroll left" again. Between these events,
                      the Charts can update mostly without the need to repaint
                      the entire panel pixel surface; since RDP will optimize updates,
                      and will send only what is required for changed pixels.

                      I posted a link to a video, showing Manual Drag Left periodically,
                      which achieves this goal, so I'll repost the link. Notice in particular,
                      that almost none of the Charting surface requires repaint, in
                      between the "drag left" events.



                      In my case, yes, I benefit from seeing the Chart pricing with
                      less Latency; but I have a Triggering system which does not
                      depend upon my reaction time. For most traders, who do use
                      manual order placement; and who use a VPS or Dedicated
                      hosted machine; this will greatly reduce their "reaction time"
                      as less I/O will be required to keep their charts current.

                      Yes, perhaps most NinjaTrader users run on a local desktop;
                      and so the unnecessary I/O is completely irrelevant. But
                      for those of us who use only Remote hosted services; this
                      simple capability would greatly improve remote response.

                      Thanks for considering this enhancement to the standard
                      Charting properties and actions.

                      hyperscalper

                      Comment


                        #12
                        Hello hyperscalper,

                        I have submitted a feature request for this sort of feature. The ticket ID is SFT-5172. This is an internal number, but for anyone else wishing to have their interest tracked, please let our support staff know that you would like a vote added for this request.

                        This idea is rather niche and may be best accomplished from a script. I encourage you to share your script on our User App Share so others that want an improved remote experience can benefit.

                        Feature Request Disclaimer

                        We receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing.

                        When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number will be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

                        Release Notes -
                        https://ninjatrader.com/support/help...ease_notes.htm

                        I look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks, Jim.

                          There is only one missing piece in my jigsaw puzzle
                          as to HOW this would be implemented, and it is simply
                          the ability to set the Active Bar to a specific X coordinate
                          on the panel.

                          Of course, as this is a GUI action; it would need to be
                          done in a Dispatch Action on the GUI thread; provided
                          that there was a way to set the appropriate variables.

                          There may be such an exposed set of variable(s) and, if
                          so, then I'd be able to create an indicator to do this.

                          Alternatively, the code needs to Simulate or Dispatch
                          Mouse Events using the Win32 API, and this is only
                          because of a lack of ability to change the X position
                          of the forming bar programmatically.

                          And one last observation: IF REMOTE USERS UNDERSTOOD
                          the underlying issues and benefits, then it would not be a "fringe request",
                          and lots of users would sign on for such a feature, I'm sure.

                          But, as you can see, even with my eloquence (LOL) take a look how
                          difficult it was for me even to communicate the idea in this
                          thread. I don't use a 9600 Baud modem; of course; since I have
                          the high speed Broadband internet that most of you have.

                          But there is no need to suffer the I/O loadings and latencies, if
                          charting is simply able to implement this behavior (for charts
                          where it makes sense).

                          hyperscalper

                          Comment


                            #14
                            Hello hyperscalper,

                            OnRender could be used to measure how many bar slots are visible in association to ChartBars.ToIndex, and once bar slots are less than X bar slots from ChartBars.ToIndex, you could call a method that invokes key presses to move the chart.

                            Code:
                            protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                            {
                                ClearOutputWindow();
                                Print(ChartBars.ToIndex);
                                Print(Math.Floor(ChartControl.GetSlotIndexByX(ChartPanel.X + ChartPanel.W))-1);
                            }
                            We don't have a documented/supported means to scroll programmatically, but this could be accomplished all the same by invoking key presses on the cursor keys. My colleague Jesse shared a RolloverIndications script that invokes key presses and that could be used to navigate that part. I have included it here for the thread's reference.

                            https://ninjatraderecosystem.com/use...indications-2/

                            I'm confident you can get something working with what is presented here for a script, and we have tracked your interest to have a feature like this implemented in the platform out-of-box.

                            If there is another topic that we can assist with, please don't hesitate to open a new thread.
                            JimNinjaTrader Customer Service

                            Comment


                              #15
                              Hi Jim. Thanks for the help.

                              I was hoping that the existing NinjaTrader Chart's code which responds to
                              a Mouse Drag Left and resets the actively forming bar,
                              could be exposed, or key variables on the
                              active bar's X position setting, were available to users.

                              But I have all of the elements necessary to implement this
                              functionality via Win32 functions on a small Indicator panel which
                              would be the target of the Mouse operations, to keep the
                              main chart, sufficiently offset from the right margin
                              periodically, as the forming bar comes within a specified
                              minimum offset % distance from the right margin.

                              It is always undesirable to have to do this via OS Win32 API
                              calls, and to simulate Mouse events; rather than directly within
                              the Chart's logic. I'm hoping this feature can be integrated
                              into an Option for Remote performance optimization across
                              Charts.

                              [edit] I've struggled with a name to label this concept, and
                              have only come up with "Auto Drag Left" or "Auto Jump Left"
                              but if you can't name something which very clearly encapsulates
                              the functionality and the benefits of the feature; then NinjaTrader
                              remote users will never recognize its importance; and it will
                              not be supported and implemented.

                              [edit2] Users who are fast scalpers, especially, will require that
                              the NinjaTrader instance is running on a server, which is as
                              close to the exchange as possible. In my case, at the moment,
                              I have a New York City hosted dedicated server; which is
                              capable of round-trip Market order completion in about
                              50 milliseconds; and which does its own local triggering; but that
                              triggering is based on my seeing the market situation with the
                              lowest possible latency, and manually enabling some triggers;
                              but, in general, most traders would prefer not to see
                              any "lag" in the charts' real time pricing status. This allows for
                              optimization of I/O (in my case, I'm located in the West, and
                              communicating with an East Coast server) so that "lag" is minimal.
                              Any unnecessary re-painting of Charting elements will necessarily
                              increase the real time lag of the Chart's image, despite powerful
                              broadband networking we all use today.

                              hyperscalper
                              Last edited by Hyper; 01-14-2021, 09:07 AM. Reason: Clarifying the value of this feature

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              15 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Started by warreng86, 11-10-2020, 02:04 PM
                              7 responses
                              1,362 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post Perr0Grande  
                              Working...
                              X