Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
These will always give you the top left corner coordinates of your chart panel..
("NOT Absolute" but chart panel relative.. so if in top panel.. normally x=0 y=0)
These will give you the far right and bottom coordinates of the chart panel...
The width and height of our panel can now be easily calculated...
To get chart panel coordinate of where the last bar should be rendered, just subtract right margin..
Since we already have the Top Left Absolute Windows Desktop Screen Coordinates of our chart window..
We can now calculate the Absolute Desktop Coordinate of first mouse down click
To Calculate the Absolute Coordinates of Mouse Move 25% left of panel width containing bars
Note: These will be off just a bit do to the toolbar, boarder widths, and such..
(which could be calculated as well) but for your current application and needs..
This should be close enough to get the job done and not have to do all that too..
OK, I did all of that, and I get pretty good results. So here's my ultimate
question for ya, Edge or anybody else:
Since nobody wants the hassle of simulating Mouse Drag, etc., how
can I simply set/reset the X position on Canvas of the "actively forming bar" by gaining
access to the Chart's variables in NT8 ??
Who do I need to talk to at NinjaTrader to find this out; or maybe one of
you vendors has a line to answer that question?
I'll post my Mouse Drag interface code; for those who might want to
do that; but let's see whether we can do it right !
Mouse Drag code (paste into Indicator) for use in OnBarUpdate, for example:
Instead of trying to use AutoHotkey.dll and other such facilities; this way is
far more controllable and instant, so is recommended.
Any such code is subject to a lot of issues; but that will emulate a
Mouse Drag; and you'll have to fill in details. If you're messing with
this, then you're competent to do all the other stuff.
Hope these fragments help someone; sorry if any errors or typos.
ANYWAY... I poked at Support, and even got the NinjaTrader Support Group Manager
involved. I was met by a flat out refusal to ask their Charting Engineering how I
might be able to set the X position of the Currently Forming Bar, from within
an Indicator.
Their model is: "We can't just go asking Engineering for stuff like that." And I
ask the question "Why not?" It's just their way of doing business. I encouraged
them, given their flat refusal, that they might find ways in the future to break
down some of the "stove pipes" and answer questions like mine in the future.....
So, given their flat refusal to help with this issue; it seems that using a Mouse Drag
operation is my ONLY choice; and that would be done through the Win32 API.
There is a suggestion that Mouse Drag events may be able to be sent to a Chart,
given the Chart's HWnd window pointer; EVEN THOUGH that Chart may not currently
have Mouse Focus. This would need to be the case; because there would be
multiple "Drag Left Indicators" on Mutiple Charts typically.
I'm just going to have to use Trial and Error here; to determine how I can do that.
And learn more about Event handling at the Windows level.
Of course, NinjaTrader could re-evaluate their willingness to help with this very simple
request; but I am not holding my breath in the meantime.
SO ANY ONE WHO IS FAMILIAR WITH "SENDING" Mouse Events to Windows; in
a manner which is "atomic" and which would work seamlessly with other Mouse
Movements in progress on other Windows; that appears to be the way forward
since that is the very LAST thing that needs to be resolved; as all of the other
requirements (such as when to trigger the "drag left") are already figured out...
REMINDER: all I want to do is to DRAG LEFT on a Charting Panel which is hosting
an Indicator, programmatically (C#) ,
from the Indicator code which will access the Win32 API to do so.
And the reason for doing this? Instead of Shifting the entire Chart's contents
left on EVERY BAR, we would Drag Left (maybe 10 bars) so it would, in many
cases, NOT be necessary for Remote VPS or Dedicated Servers to send
redraws of Chart contents on every BAR advance. HUGE reduction in I/O
requirements for remotely accessed servers running NT8 via Remote Desktop.
Have you explored creating a new BarsType and manipulating its date?
I've in the past created a BarsType which re-values its PRICE, so it has its own OHLC by looking at the OHLC of some other bar (placed in another panel but within the same chart window) and then applying mathematical manipulations.
Although I haven't tried DATE manipulations, it should theoretically be possible to do something similar...
In your case you're using tick charts. I'd try creating a new BarsType, and have it constantly recalculate its own date based on the last ticks bar's datetime. This way it may be possible to keep the new BarsType constantly anchored to the same spot on the X-axis in its own panel (while the ticks bars, and their indicators, build in other panels).
Finally, get the chart to refresh only when the new BarsType's datetime needs refreshing.
THANK YOU so much for your idea. I am not sure it will allow for the "periodic drag left"
which is the objective. A constant alignment on EACH bar still requires the entire
chart to the left, to be RE-DRAWN on EACH bar, and that is what we are trying to minimize by
"dragging the chart left" or "shifting the chart left" only e.g. after every 10th bar; or after
the current bar hits the right margin.
The Win32 API permits us to send Mouse Events and "drag the chart left"; but I fear that
it may be a FRAGILE solution with multiple "drag" indicators on multiple charts operating
independently. Perhaps not, since maybe we can send Mouse Events in a "transaction"
or "atomic" sequence; and by saving/restoring the active HWnd, then perhaps it would
work seamlessly..... but this is where my experience is limited.
I hope I didn't misunderstand your proposed solution...?
PLEASE REFER TO THIS VIDEO TO SEE WHAT I'M TRYING TO ACCOMPLISH:
That is Remote Desktop running on a dedicated server; using a fast 1 second chart
which will be forced to shift the entire chart image on EACH bar; unless the "drag left"
is done periodically, as shown.
If you do figure out how to drag the chart with a simulated mouse event, please do post. I started a thread on NT on how to do this... I was recommended an indie that does this, but was too complicated.
If you figure out the minimum amount of code to accomplish this, please do post.
Will do, if/when a "clean" solution is found. I can "hack" various solutions; but they
are not general enough.
BEST WOULD BE IF NINJATRADER CHARTING ENGINEERING WOULD SIMPLY TELL US
HOW WE CAN SET THE X POSITION OF THE CURRENTLY FORMING BAR DIRECTLY
FROM THE INDICATOR. I think the value of this is pretty convincing when you
consider the video posted above. Yes, NinjaTrader is typically used as a "desktop"
app; but for those of us to maintain Dedicated remote servers, or VPS servers; having
efficient I/O between the Remote Desktop server and local client is very important.
If you're already almost there with the mouse-drag solution, there's really no point taking another route.
But just to explain the idea, look at how NinjaTrader deals with multi-timeframe charts like the one below (it'll be even more obvious if you overlay say 15min on 60 min, or 60 min on 1 day, etc). There seems to be some kind of pro-rating going on, with NT distributing the space available on the X-axis by approximating date/time values.
But in all cases, the latest candle in terms of timestap is what would print on the far right.
The idea is to create a fictitious candle, forwarded in time with say 15 minutes, or maybe given a fixed date "tomorrow". I'm hoping that fictitious candle will remain THE right most candle, while the ticks bars play catch-up. If THEIR dates are always earlier than that fictitious candle, they should paint farther to the left of it, i.e. somewhere in the middle of the chart window.
And just when the ticks candles are about to catch up with that "tomorrow" candle, we reset its date so that again it distances itself from the ticks bars, forcing NT to recalculate and pro-rate their positions since their timestamps are behind the tomorrow candle. As the ticks bars try to play catch-up again, they should paint somewhere in the middle. The chart is refreshed only once every so often, when we create a new date for the "tomorrow" candle.
So basically the idea is to make the ticks bars play catch-up to a tomorrow that never comes. It might work if you're looking for an all-Ninjascript approach.