I am currently using ChartScale inside OnRender to figure out the price from a mouse click. My issue is if I want to draw a line based on that price, there will be a delay. Onrender is only called every 0.25 seconds and even with ForceRefresh() there is a visible delay between when the user clicked on the screen and the drawing showing up.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
On Render issue NT8
Collapse
X
-
On Render issue NT8
Is there any way to get the price from a mouse click without using on render?
I am currently using ChartScale inside OnRender to figure out the price from a mouse click. My issue is if I want to draw a line based on that price, there will be a delay. Onrender is only called every 0.25 seconds and even with ForceRefresh() there is a visible delay between when the user clicked on the screen and the drawing showing up.Tags: None
-
Hello trader3419,
Thank you for your post.
You could in fact create event handlers for the mouse clicks. You can find an article on mouse events at the following link: http://www.codeproject.com/Articles/10570/Mouse-Events
Please let me know if you have any questions.
-
Thank you Patrick. How does that solve my issue of having a delay in the drawing object showing up after I clicked? because currently.
I click on the screen
Force Refresh
On Render(), I now have access to chartscale to get the price and I draw the object
Force Refresh
Now the object shows up after onrender is called again
That is currently what I am doing and what understand happens.
How can I improve on this so that the drawing object will show up automatically after the mouse is clicked?
Comment
-
This is an indicator that is getting mouse input and using Draw.Ray inside of OnRender.
Sorry for not clarifying earlier.
Comment
-
-
Hello trader3419,
Thank you for your patience.
So we still need OnRender() for one item, we need to get the scale of the chart from OnRender(). However, we don't have to do that on each click and therefore do not need to wait for an OnRender() pass for our mouse event.
Attached is an example that shows how to use the MouseDownEventHandler to track when a mouse event occurs and print the Y value of the chart. It's important to note that we need the chart's scale from OnRender() to know where the Y is in relation to price.
Please let me know if you have any questions.Attached Files
Comment
-
Wow! I am excited to dig into this once I get a chance today. Just from reading your posts, it seems like it is what I have been searching for! I will keep you posted with my results.
Thanks Patrick
Comment
-
That was awesome. Thank you.
I don't have to use OnRender anymore and things are running much more smoothly.
Much appreciated Patrick!
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mongo, Yesterday, 11:05 AM
|
6 responses
27 views
0 likes
|
Last Post
by Mongo
Today, 07:12 AM
|
||
Started by ct, 05-07-2023, 12:31 PM
|
7 responses
206 views
0 likes
|
Last Post Today, 07:11 AM | ||
Started by wzgy0920, Yesterday, 09:53 PM
|
1 response
13 views
0 likes
|
Last Post Today, 07:06 AM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Yesterday, 07:51 PM
|
1 response
12 views
0 likes
|
Last Post Today, 06:59 AM | ||
Started by kaywai, Today, 06:26 AM
|
1 response
6 views
0 likes
|
Last Post
by kaywai
Today, 06:35 AM
|
Comment