Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Shift Chart Image to Left programmatically ?

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

    #16
    So, after all my explanations; and the video support; you still don't understand
    that I want to periodically "drag left" programmatically; to minimize remote viewing I/O.

    Honestly, I am unhappy with this thread; and am almost sorry I even brought
    it up.

    It is such a simple request; but apparently you still don't understand it.
    So, with all due respect, I give up on this topic.

    hyperscalper
    Last edited by Hyper; 12-15-2020, 08:51 AM.

    Comment


      #17
      Hello Hyper,

      I understand that you want to move the chart, I had provided suggestions on how you could do that in my first reply, post #2. There is no API for that, you would have to use WPF events. At this point I am unsure what you need help with in regard to that.

      Moving the chart is not an item that there is a specific API for in NinjaScript, you would need to use WPF events if you want to simulate user input. That would include using keyboard events to trigger chart keyboard commands or mouse events.

      The Rollover indications indicator shows how to send key events to the chart so that is likely the best starting point toward doing this yourself. The help guide contains the supported keyboard events, you could send right arrow a number of times to move the chart over.

      If you wanted this feature today you could use NinjaScript to do that using the items I had mentioned in post 2 or other WPF means of input control.


      Please let me know if I may be of further assistance.

      JesseNinjaTrader Customer Service

      Comment


        #18
        Hi,

        You said: "If you wanted this feature today you could use NinjaScript to do that
        using the items I had mentioned in post 2 or other WPF means of input control."

        So prove it to me providing a code snippet, or even a pseudo-code explanation.

        When the Tick chart reaches the rightmost Price scale; detect that; and then Scroll the chart
        to the left in code.

        I'd like a "second opinion" from a more Senior support specialist; that proves you at least
        understand my request. If the request isn't understood, then a solution can't be provided.

        I don't want to have to create User Input actions simulated; if I wanted to do that,
        I could use AutoHotKey or some such facility. But I want to do it by accessing the
        key chart control variables; if they are accessible. So... what are these variables
        to achieve a Scroll Left ?

        hyperscalper
        Last edited by Hyper; 12-15-2020, 10:05 AM.

        Comment


          #19
          Hello Hyper,

          So prove it to me providing a code snippet, or even a pseudo-code explanation.
          I had provided an explanation of what to do in the previous reply. If you want to move the chart you could send an right arrow key. I provided a link to an indicator that uses an unsupporrted way to send keys to the chart. If part of that's not clear please clarify what you need help with.

          I don't want to have to create User Input actions simulated; if I wanted to do that,
          That is what is going to be needed here because there is not an API or properties to move the chart around. If you want to use NinjaScript to move it you can by using unsupported WPF key events to simulate user input. You would send the right arrow key if you wanted to move the chart left.



          Please let me know if I may be of further assistance.






          JesseNinjaTrader Customer Service

          Comment


            #20
            Here is my pseudo-code in NinjaScropt:


            private bool chartIsAtOrBeyondRightMargin() {
            return false; // TODO what is the condition to test?
            }

            private void scrollChartLeft() {
            // TODO how can this be done?
            }

            protected override void OnBarUpdate()
            {
            if (chartIsAtOrBeyondRightMargin()) {
            scrollChartLeft();
            }
            }


            and, finally, since you say there are no accessible
            chart control variables; I was originally requesting that
            they be made accessible. And further, I was suggesting
            that an AutoScrollLeft feature might even be provided
            in the standard Chart properties for the future.
            Last edited by Hyper; 12-15-2020, 10:32 AM.

            Comment


              #21
              I do want to thank you for the link to the Rollover Indicator code; which
              does illustrate a lot of advanced capabilities. Thanks.

              Comment


                #22
                By way of partial closure on this subject; I was able to achieve
                my goals of an "Auto Jump Left" scroll within some constraints,
                which are not worth further refining.

                The critical details involve knowing then the current bar is
                within range of the right margin, so that it requires to be shifted
                left by simulating a Mouse Drag. (discussed elsewhere)

                Then the most difficult part was to simulate the Mouse Drag, which
                does require an absolute screen display x, y and a number of
                pixels to drag left to an x2, y. In this case, the location x,y does
                need to remain uncovered on the chart; but that's not a serious
                restriction for me.

                C# code to to the WPF compatible drag, can be found in this post, and just pasted
                into your Indicator:
                https://stackoverflow.com/questions/...use-click-drag

                Code:
                DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
                private static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, uint dwExtraInfo);
                
                [DllImport("user32.dll")]
                static extern bool SetCursorPos(int X, int Y);
                
                const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
                const uint MOUSEEVENTF_LEFTUP = 0x0004;
                const uint MOUSEEVENTF_MOVE = 0x0001;
                
                static void Drag(int startX,int startY,int endX,int endY)
                {
                endX = endX - startX;
                endY = endY - startY;
                SetCursorPos(startX, startY);
                mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                mouse_event(MOUSEEVENTF_MOVE, endX, endY, 0, 0);
                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                }
                Using a tool like WinSpy, a reasonable x,y can be found; and
                that can be put into a file so the Indicator can read those values.

                As I said, that area should be left uncovered; and code can be written
                to "drag left" when the currently forming bar is within, say, 5%
                of the right margin; and dragged back a reasonable pixel amount so
                that many subsequent bars can form without each bar's triggering a left
                scroll of the chart; which achieves the goal of reducing remote connection
                bandwith very nicely in most cases.

                Originally I wanted to request this be a mode which charts could set
                in a future version of NinjaTrader 8; but I doubt that will ever happen.

                I'll make a teensy video of this in action; and edit that link in.

                [edit] https://youtu.be/biqcvSCnvs8 shows behavior under very slow
                market conditions; but during faster conditions, it's absolutely essential
                to hugely reducing I/O requirements when viewed on remote dedicated
                servers or VPS servers.

                [edit] Logic necessary to determine where the actively forming bar is,
                relative to the chart canvas coordinates can be found here:
                https://ninjatrader.com/support/foru...ar#post1133648

                Thus, the active bar position can be determined to be "near enough"
                to the right margin to initiate some drag left operation. Lots of refinement
                is possible; but for now, it's close enough for my needs.

                hyperscalper
                Last edited by Hyper; 12-29-2020, 12:14 PM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by AlexsOptions, Today, 05:42 PM
                1 response
                7 views
                0 likes
                Last Post bltdavid  
                Started by philli4093, Today, 05:20 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by memonolog, Today, 04:58 PM
                0 responses
                1 view
                0 likes
                Last Post memonolog  
                Started by robvul, Today, 04:20 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by sandman, Today, 01:54 PM
                3 responses
                24 views
                0 likes
                Last Post NinjaTrader_Jim  
                Working...
                X