Snapping Drawings to Nearest Tick - NinjaTrader Programming | futures io social day trading
futures io futures trading


Snapping Drawings to Nearest Tick
Updated: Views / Replies:1,459 / 10
Created: by Xav1029 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

Snapping Drawings to Nearest Tick

  #1 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received

Snapping Drawings to Nearest Tick

Got an alert system I'm working on that sends alerts from SR lines. The indicator draws lines that can then be adjusted by the user. My question is when I am in adjust mode, how do I make sure that the lines I am adjusting get rounded to the nearest tick like the chart trader lines?

When the user clicks the draw/remove button, targets, stops, and SR lines are drawn or removed. When they get drawn, the indicator goes into adjust mode. While in adjust mode, all the levels are unlocked and can be moved by the user. When the user is moving these levels, I would like them to snap to rounded ticks like chart trader targets. Also, while the user is moving them, I would like the labels to be anchored to the lines so that they move with the lines in real time. Right now the values get snapped and the labels are moved once the user presses the set button.

Any ideas on how to do this? I was thinking to put it inside a timer, and round it 10x a second or something, but don't know if this would be the most efficient way to do it.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

London Calling
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 received


Maybe make it so it rounds every mouse click? Then it will round as they drop it?

Reply With Quote
 
  #4 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


vegasfoster View Post
Maybe make it so it rounds every mouse click? Then it will round as they drop it?

That is an option... I could run the timer, round, and move the labels as long as the left mouse button is being held. I will look into that option.

London Calling
Reply With Quote
 
  #5 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


Xav1029 View Post
That is an option... I could run the timer, round, and move the labels as long as the left mouse button is being held. I will look into that option.

Yes, I would tie it to mouse clicks too, only in adjust mode though, no need to run through it all the time.
Moving the labels real time is rather expensive, you would need to permanently get Y coordinate of the mouse while left button is down.
Flag or dynamic eventhandler when left mouse gets clicked in adjust mode, don't know which is cheaper. And then redraw the labels on mouse move (only if Y changes, no need to do it on X change, the checking will be cheaper than the redraw).

vvhg

Hic Rhodos, hic salta.
Reply With Quote
The following user says Thank You to vvhg for this post:
 
  #6 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


vvhg View Post
Yes, I would tie it to mouse clicks too, only in adjust mode though, no need to run through it all the time.
Moving the labels real time is rather expensive, you would need to permanently get Y coordinate of the mouse while left button is down.
Flag or dynamic eventhandler when left mouse gets clicked in adjust mode, don't know which is cheaper. And then redraw the labels on mouse move (only if Y changes, no need to do it on X change, the checking will be cheaper than the redraw).

vvhg

@vvhg could you post a snippet that would trigger an event every 100ms? I've never worked with timers, so don't know where to begin. Also do I use ChartControl.ActiveControl to figure out which object is selected? Since the lines are drawn internally, I know the tags. I don't want to adjust labels that don't need to be adjusted to keep it as "cheap" as possible lol. So I'm thinking to just return on the timer event if not in adjust mode. Then have a bool that is set to true on mouse down, false on mouse up. Return on the timer event if that bool is false. If it is in adjust mode, bool is true, and the active control is one of the drawn lines, then adjust the labels and rounded to the nearest tick. To save some cycles, I will just round and adjust the label. I will round the actual line y value to the nearest tick once the user locks("set") the levels.


Sent from my iPhone using Tapatalk

London Calling
Reply With Quote
 
  #7 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


Xav1029 View Post
@vvhg could you post a snippet that would trigger an event every 100ms? I've never worked with timers, so don't know where to begin. Also do I use ChartControl.ActiveControl to figure out which object is selected? Since the lines are drawn internally, I know the tags. I don't want to adjust labels that don't need to be adjusted to keep it as "cheap" as possible lol. So I'm thinking to just return on the timer event if not in adjust mode. Then have a bool that is set to true on mouse down, false on mouse up. Return on the timer event if that bool is false. If it is in adjust mode, bool is true, and the active control is one of the drawn lines, then adjust the labels and rounded to the nearest tick. To save some cycles, I will just round and adjust the label. I will round the actual line y value to the nearest tick once the user locks("set") the levels.


Sent from my iPhone using Tapatalk

Hmmm, I don't think a timer makes much sense, as you need the mouse move event either way (for the current Y value). Then starting and stopping the timer on mouse move would probably be more expensive than returning on the mouse move event. What you could better do is only subscribe to the event when needed, so in adjust mode.

You could have a look at the vvTrendLineTrader code for the mouse events, and at vvSuperGauge for converting mouse-Y to price if you need that. I can not provide any snippets now as I am away from the computer, so you would havet to wait until tomorrow.

Vvhg

Hic Rhodos, hic salta.
Reply With Quote
The following user says Thank You to vvhg for this post:
 
  #8 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received


vvhg View Post
Hmmm, I don't think a timer makes much sense, as you need the mouse move event either way (for the current Y value). Then starting and stopping the timer on mouse move would probably be more expensive than returning on the mouse move event. What you could better do is only subscribe to the event when needed, so in adjust mode.

You could have a look at the vvTrendLineTrader code for the mouse events, and at vvSuperGauge for converting mouse-Y to price if you need that. I can not provide any snippets now as I am away from the computer, so you would havet to wait until tomorrow.

Vvhg

@vvhg I will take a look at those two tools. I just need to make sure that on the mousemove event, one of the levels are actually being moved. Off the top of your head, do you know if one of those two tools checks if you are moving lines in the mouse events? I'm not in front of my computer either, so can't check now.

London Calling
Reply With Quote
 
  #9 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received

Crude Example

OK so I stole most of this code from @vvhg, and the rest I stole from NT support forum. This basic tool is just an example of what I was trying to do. What it does is check if a horizontal line is selected, and if it is it changes the color to red and adds a label. Just like the chart trader lines, once selected, you can move the line, and it will always round it to the nearest tick. The label follows the selected line. When a line is selected it is red, and returns to original color when you deselect it. Right now the label stays on the chart, and is not formatted, but I am tired and the point of this thread was to figure out how to do what I explained in the first post. Feel free to steal this code and make something useful out of it. I am working on an alert system that will use this, and once I finish the alert system, you will easily be able to create a strategy that uses the shell and be able to tie stops and targets to horizontal lines just like the chart trader Pretty much you will be able to run sophisticated ATM's and manage them just like the chart trader ATM's

London Calling
Attached Files
Register to download File Type: zip XavTickRoundLabelTest.zip (2.4 KB, 25 views)
Reply With Quote
The following user says Thank You to Xav1029 for this post:
 
  #10 (permalink)
Elite Member
prague, czech republic
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: ES
 
Posts: 88 since May 2012
Thanks: 30 given, 41 received



Xav1029 View Post
OK so I stole most of this code from @vvhg, and the rest I stole from NT support forum. This basic tool is just an example of what I was trying to do. What it does is check if a horizontal line is selected, and if it is it changes the color to red and adds a label. Just like the chart trader lines, once selected, you can move the line, and it will always round it to the nearest tick. The label follows the selected line. When a line is selected it is red, and returns to original color when you deselect it. Right now the label stays on the chart, and is not formatted, but I am tired and the point of this thread was to figure out how to do what I explained in the first post. Feel free to steal this code and make something useful out of it. I am working on an alert system that will use this, and once I finish the alert system, you will easily be able to create a strategy that uses the shell and be able to tie stops and targets to horizontal lines just like the chart trader Pretty much you will be able to run sophisticated ATM's and manage them just like the chart trader ATM's

It is great! But unfortunately it is not possible to change color of a line... It is the only disadvantage! Would it be possible to make available this change?
And I would also like to ask, how is it possible to add the label?

Reply With Quote

Reply



futures io > > > > > Snapping Drawings to Nearest Tick

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save drawings on TOS TRIPLETOP ThinkOrSwim 12 July 5th, 2015 12:00 AM
ToS quick help: Seperate drawings for each chart? grimReaper ThinkOrSwim 6 January 23rd, 2012 12:27 PM
how to extract nearest support price from arraylist? zacharydw00 NinjaTrader Programming 15 January 1st, 2012 02:57 AM
How do you allow drawings out of chart visible area? Default User NinjaTrader Programming 7 June 27th, 2011 09:20 PM
Clear All Drawings on a Ninja 6.5 Chart? TraderJesse NinjaTrader Programming 5 March 12th, 2010 03:59 PM


All times are GMT -4. The time now is 01:18 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.15 seconds with 20 queries on phoenix via your IP 54.92.201.232