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, 09: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, 11: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, 11: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:
                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


                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, 01:14 PM.

                Comment


                  #23
                  A semi-automated way by using a AutoHotKey Script.

                  Here's a working Short AutoHotKey Script version example (also attached the .ahk).

                  Code:
                  SetTitleMatchMode 2
                  
                  
                  #IfWinExist, CL
                  
                  End::
                  ShiftLeft:
                  Loop, 25
                  {
                       Send, {Right}
                  }
                  Return
                  When pressing the End key, it executes 25 Right Arrow keystrokes (On a Chart containing the "CL" substring (without quotations marks) in its title).
                  (the mouse cursor needs to be on the main Chart window, not the Tools Bar or ChartTrader, else it can mess things)

                  Below the long version of the same AutohotkeyScript created with Pulover macro Creator
                  Download Pulover's Macro Creator Download Current Version: 5.4.1 Other download options on GitHub Do you like PMC? Consider making a donation and support development. Latest changes: [read full changelog] Version 5.4.1 Added a sleep when collecting data to save project to improve reliability. Fixed bug with escaped characters in expressions. Fixed Until option unchecked when

                  (it works as well but better use the short version above, this one is the raw recorded macro)

                  Code:
                  ; This script was created using Pulover's Macro Creator
                  ; www.macrocreator.com
                  
                  SetTitleMatchMode 2
                  
                  
                  #NoEnv
                  SetWorkingDir %A_ScriptDir%
                  CoordMode, Mouse, Window
                  SendMode Input
                  #SingleInstance Force
                  SetTitleMatchMode 2
                  #WinActivateForce
                  SetControlDelay 1
                  SetWinDelay 0
                  SetKeyDelay -1
                  SetMouseDelay -1
                  SetBatchLines -1
                  
                  #IfWinExist, CL
                  
                  
                  
                  End::
                  ShiftChart:
                  #IfWinExist, CL
                  Sleep, 33
                  Sleep, 51
                  #IfWinExist, CL
                  Click, 36, 18 Left, Down
                  Sleep, 25
                  Click, 36, 18 Left, Up
                  Sleep, 60
                  Send, {Right}
                  Sleep, 29
                  Send, {Right}
                  Sleep, 23
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 18
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 18
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 18
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 25
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 23
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 23
                  Send, {Right}
                  Sleep, 21
                  Send, {Right}
                  Sleep, 20
                  Send, {Right}
                  Sleep, 36
                  Send, {Right}
                  Return
                  Attached Files
                  Last edited by PaulMohn; 01-28-2022, 10:44 AM.

                  Comment


                    #24
                    I appreciate the information, but I need an Indicator to run on the chart, which automates this, and can handle multiple charts automagically...
                    I asked for a solution, and it was refused; but I believe the approach will be to use a Win32 call to Send Mouse/Keystrokes to the enclosing
                    chart, but I just put it on the back burner and will be looking at it again. Embedded AutoHotkey was one solution path I looked at, but I
                    think the Win32 sending of simulated events like Cntl and Mouse Wheel movements is likely to be the solution; it must not interfere with
                    any ongoing Mousing over charts, etc.... so it's a challenge, since they wouldn't give me a direct solution to the problem.
                    hyperscalper

                    Comment


                      #25
                      It would be nice to have a shift button like in Metatrader (to keep the price series at a fixed and static distance from the right border).
                      That way it would remain at say 25 Right Keystrokes from the right border all the time and update from that coordinate.

                      Here's the Metatrader Shift feature (Interactive Brokers also has a similar feature):
                      (from section How to shift and adjust MT4 charts)



                      Click image for larger version

Name:	manage-charts-mt4-5.jpg
Views:	136
Size:	101.1 KB
ID:	1187481

                      Comment


                        #26
                        Well, I run on a remote hosted colocated server; and I need all of my charting to do periodic
                        "jump scroll to the left" which will minimize my I/O over Remote Desktop. That was the
                        original rationale, and I'll eventually code something that works the way I need it to.
                        But NinjaTrader is not often used on colocated servers, apparently; and so they said
                        nobody would be interested in such a feature. lol I probably said this before,
                        but, as Deckerd said in "Blade Runner"... something like "I was quit went I walked
                        in here, and I'm twice as quit now." with this thread... after all the effort I put into
                        explaining it, a waste of my time... so I am quit.
                        Last edited by Hyper; 01-28-2022, 11:20 AM.

                        Comment


                          #27
                          I found something that might help (you might need to adapt it).
                          This ChartStyle script uses a "Base Width" control property that left-shifts the Bars and keeps them at a predefined distance from the right border
                          https://ninjatraderecosystem.com/use...ars-option-v1/

                          The max value is 100, and it left-shift to about half an inch

                          Click image for larger version

Name:	baseWidth.png
Views:	101
Size:	881.6 KB
ID:	1189352
                          Attached Files
                          Last edited by PaulMohn; 02-10-2022, 06:08 AM.

                          Comment


                            #28
                            Thank you, but I don't think that meets the requirement. If the chart image shifts to the left on EVERY new bar, then it does not satisfy what I need. I need to simulate a "Drag Chart Left" periodically, so that New Bars may form for a while, without requiring the shifting of ALL prior bars to the left on the charting image. Once the New Bar reaches the right margin, then the "Drag Left" operation will be repeated. Thanks anyway ! hyperscalper

                            Comment


                              #29
                              Oh ok I see.

                              Another idea. Would it be possible for your use to set a secondary AutoHotKey loop to execute say every 10 seconds for a period of however long you have to run it (1 hour, 2 hours etc.)?
                              If it's resources efficient, maybe putting the previous AutohotKey loop in a 2nd and a 3rd loop, to execute say every 10 seconds or so for a duration of 1 hour?

                              Not sure how to formulate it but I found some ideas here.



                              The Loop statement performs one or more statements repeatedly: either the specified number of times or until Break is encountered.


                              Run loop every 3 minutes endlessly - posted in Ask for Help: I am new to this. I am trying to run this every 3 minutes, with and endless loop and 1 as the stop key WinWait, Program Manager, IfWinNotActive, Program Manager, , WinActivate, Program Manager, WinWaitActive, Program Manager, Send, {PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP}{PGUP} WinWait, RightBed :: Bed Board - Windows Internet Explorer, IfWinNotActive, RightBed :: Bed Board - Windows Internet Explorer,...



                              Something like

                              Stop after 1 hour
                              Execute every 10 seconds
                              executes 25 Right Arrow keystrokes

                              Comment


                                #30
                                Because my request was initially not even understood correctly, despite my efforts to explain, and also because even management and a support guy were in a phone call to me, where I again explained what and why... and they flatly refused any help in setting of the Charting variable controlling the X position of the Currently forming Bar... because of all that, I just gave up. Normally, this forum will support odd requests, or advanced requests; but it's hit or miss depending on the motivations and abilities of whomever gets assigned to answer your issue. Anyway, YES, it is true that since they will NOT tell us how we can set the appropriate Chart variable, then using Win32 functions to send Mouse, or Keyboard events to the panel remains the only solution. When you have a dozen charts, each of which you need to have that behavior, then the simplistic AutoHotKey solutions become impractical or impossible. And because you need to interfere with the basic I/O system in order to send Events, there is a high probability that such a solution will interfere with ongoing Mouse or Keyboard behavior, and so... it becomes a Rat's Nest Hack. Nevertheless, I am close to finding a solution to this, without any further "assistance" from platform support. I appreciate that you have tried to come up with solutions, but it's a problem which requires Charting Engineering to expose the setting of the Currently Forming Bar's X position; otherwise the solution is very difficult, and "hit or miss". And they're NOT gonna help in that way...

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Radano, 06-10-2021, 01:40 AM
                                19 responses
                                605 views
                                0 likes
                                Last Post Radano
                                by Radano
                                 
                                Started by KenneGaray, Today, 03:48 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post KenneGaray  
                                Started by thanajo, 05-04-2021, 02:11 AM
                                4 responses
                                470 views
                                0 likes
                                Last Post tradingnasdaqprueba  
                                Started by aa731, Today, 02:54 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post aa731
                                by aa731
                                 
                                Started by Christopher_R, Today, 12:29 AM
                                0 responses
                                11 views
                                0 likes
                                Last Post Christopher_R  
                                Working...
                                X