Recent

Author Topic: Distance measurments  (Read 1209 times)

chucky

  • New Member
  • *
  • Posts: 40
Distance measurments
« on: February 11, 2025, 05:48:51 pm »
Im trying to implement a chart tool to display distance on my financial chart. The ChartToolset1DataPointDistanceTool just measures the distance from the starting origin.

What I need is to draw the same line that this tool does, but also draw a rectangle from the origin to destination and for one of the  vertical lines in the rectangle to displace the change in stock price (the Y axis) in % change, positive if its climbing, negative if its decreasing.

For the horizontal I need to displace the change in time (X axis).

My question is: should I use the distance tool or would it be better to use a UserDefined tool. Does it really matter that much?

If I I'm thinking about this correctly then if I use the UserDefined tool I have to define a storage variable  and write to it at the beginning of the mouse drag? And update another storage varible for the destination. I guess they are already provided in the distance tool so if I'm using that I just have to redisplay the rectangle as the mouse is moving?



wp

  • Hero Member
  • *****
  • Posts: 12703
Re: Distance measurments
« Reply #1 on: February 11, 2025, 07:27:07 pm »
Could you draw a sketch? Or post a link to a site where you have seen this.

chucky

  • New Member
  • *
  • Posts: 40
Re: Distance measurments
« Reply #2 on: February 12, 2025, 06:31:07 pm »
I use Interactive Brokers trader workstation. They have a distance tool which pretty much works like the TChart distance tool but it doesnt snap to a datapoint. It simple draws your line on the graph and always uses the price axis and displays the % change from the point you started from to the point you ended at. This is a very useful tool to check the size of the swing in price movement. It would be even more useful if it drew a rectangle with the starting and ending drag and calculate both the price and time movement and the slope of the dragged line.
 

wp

  • Hero Member
  • *****
  • Posts: 12703
Re: Distance measurments
« Reply #3 on: February 12, 2025, 07:10:19 pm »
Sorry, I still don't get it. Can't you post a screenshot of a chart created by them?

Did you run the demo in folder demo/distance of the TAChart installation? Did you see the properties of the distance measurement tool? DataPointModeStart and End can be set to avoid snapping to data points.

"It always uses the price axis" - does this mean that the drawn measurment line should be horizontal? In this case you'd have to set MeasureMode to cdmOnlyX.

"Displays the % change..." - The text to be displayed along the measurement line can be composed either in the Marks property or in the OnGetDistanceText event handler.

chucky

  • New Member
  • *
  • Posts: 40
Re: Distance measurments
« Reply #4 on: February 13, 2025, 11:24:30 am »
wp,
I attached a screenshot for your review. This is a partial price/time chart for NVIDIA common stock taken Feb 12 2025 displaying

1 minute ohlc bars series
purple line is a 9 period EMA (Exponential moving average
white line is a 21 period EMA

and a straight blue line which is displaying the price movement from start to end in % change. This is what I'm trying to do with the distance tool except I guess I'm not really measuring distance. It is taking the starting price and the ending price and calculating the % change which allows me to quickly determine a profit/loss level and compare it to other stocks that I'm tracking in real time.

The part I mentioned about drawing a rectangle was to draw it with the starting point as the lower left corner and the upper right corner being the ending point with the distance line splitting the rectangle from lower left to upper right.

Then I want to display the % change at the top left corner. The reason I want to display it this way is I can, at a quick glance, see the price movement and easily see the % change because a lot of times the distance line will be passing though the ohlc bars and is difficult to see. And because I'm drawing the rectangle it would be easy to go ahead and add  distance measurement text near the bottom right corner.

Can the distance tool be used for this kind of application? Or start with a custom tool?
It would be nice if several lines could be drawn and displayed.

Thanks for your time.

Cheers!

Thaddy

  • Hero Member
  • *****
  • Posts: 16672
  • Kallstadt seems a good place to evict Trump to.
Re: Distance measurments
« Reply #5 on: February 13, 2025, 11:43:12 am »
You need to design it such that you log the data in memory/fast storage and present it as a current sample of it and then discard the memory of it. That way you decouple plesentation layer from actual data, which you will still be able to store for future analysis. Then usually presentation is the most compute expensive part. (compute basics)

Why? because the raw data needs to be scaled and that can be a long operation, use samples instead, and when your data is really collected THEN you present it again off-line.
To show if the samples missed an event.
That's how scientist do it for decades.

Trust me, data presentation can not be done in real time in the digital domain, so you have to log the data first.
Depending on the data speed, you can put a 10,100,1000 etc scale for the frame rate you monitor can manage.

The analog domain is a different matter: in a full analog domain a cathode ray tube can follow a signal perfectly but can.t be logged other than noise.
« Last Edit: February 13, 2025, 12:05:13 pm by Thaddy »
But I am sure they don't want the Trumps back...

wp

  • Hero Member
  • *****
  • Posts: 12703
Re: Distance measurments
« Reply #6 on: February 13, 2025, 12:53:34 pm »
In the attachment there is a modified version of the "financial" demo project of TAChart. It is extended by a distance measuring tool which is activated by SHIFT + left mouse button drag. There are two display modes: either as a simple line annotated by the relative change in stock price, or as a shaded rectangle with line annotated in the same way (but at a different place in code due to the custom-drawing).

Thaddy

  • Hero Member
  • *****
  • Posts: 16672
  • Kallstadt seems a good place to evict Trump to.
Re: Distance measurments
« Reply #7 on: February 13, 2025, 01:49:19 pm »
That is called sampling, wp  ;)
But I am sure they don't want the Trumps back...

chucky

  • New Member
  • *
  • Posts: 40
Re: Distance measurments
« Reply #8 on: February 14, 2025, 04:08:44 pm »
Well this is not sampling. These are 1 minute bars and the fast and slow ema's are calculated once each minute. Yes the algorithm underneath is receiving a constant stream of trade tick data and assembling it in what ever size records happen to be needed for the complex calculations to determine if a trade event should be triggered. But these operations have no frontend, neither a console or xwindow graph. The graph is simply calculated from historical data, albeit only a few seconds or minutes old, from the time the algorithm processed it in real time. This slow human interface is begin used by a human to issue commands to steer the algorithm in the right direction. Decisions like the size bars, use the crossover point in the fast and slow ema's, or use a change in the slope of the fast ema and its distance form the slow ema, or even switch algorithms. The graphing utility  is not sampling real time data.

The size bars being assembled from the algorithm range from millseconds to seconds which are being used by the algorithm itself, and bars in the second to minute range which is made available if needed, by the graphing program for human consumption.

All that said, is I've been trying to get help from someone who is knowledgeable with the charting software. I suck at it. I'm a fairly good programmer dealing with the discipline I majored in which isn't desktops and graphical interfaces.

There has always been, and always will be, a disconnect between the programmer and the engineer.

Cheers!

Thaddy

  • Hero Member
  • *****
  • Posts: 16672
  • Kallstadt seems a good place to evict Trump to.
Re: Distance measurments
« Reply #9 on: February 14, 2025, 04:31:32 pm »
Well this is not sampling. These are 1 minute bars and the fast and slow ema's are calculated once each minute.
So, you are saying it's not sampling and then blatantly obvious explain that what is does is for all intend and purpose bloody sampling,,,

As I already wrote.
You must have a rather strange understanding of sampling....
But I am sure they don't want the Trumps back...

chucky

  • New Member
  • *
  • Posts: 40
Re: Distance measurments
« Reply #10 on: February 14, 2025, 04:36:16 pm »
Why dont you be constructive and help me understand how to implement the stated problem or stay off the topic and quit wasting everyones time?

Thaddy

  • Hero Member
  • *****
  • Posts: 16672
  • Kallstadt seems a good place to evict Trump to.
Re: Distance measurments
« Reply #11 on: February 14, 2025, 05:40:54 pm »
I already did that, but you do not listen: I gave step by step instructions what is required.

Wouldn't you be annoyed?

https://forum.lazarus.freepascal.org/index.php/topic,70196.msg547035.html#msg547035
« Last Edit: February 14, 2025, 05:43:23 pm by Thaddy »
But I am sure they don't want the Trumps back...

 

TinyPortal © 2005-2018