Angle of a line / Tick Data  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
lordongi
Posts: 29
Joined: 18 Dec 2017
Has thanked: 10 times
Been thanked: 3 times

Angle of a line / Tick Data

Postby lordongi » 22 Sep 2023

Hi,

I created some indicators that calculate the angle/steepness of a line/trendline.
I use this code, that works fine für time based charts (like minute charts).

Code: Select all

.... double x1 = BarsOfData(0).Time[highestCumIndex].Ticks / TimeSpan.TicksPerMillisecond; double x2 = BarsOfData(0).Time[0].Ticks / TimeSpan.TicksPerMillisecond; angle = CalcAngle(x1, x2, highestCum, BarsOfData(0).CloseValue); .... double CalcAngle(double x1, double x2, double y1, double y2) { double xDiff = x2 - x1; double yDiff = Math.Abs(y2 - y1); const double Rad2Deg = 180.0 / Math.PI; double result = Math.Atan2(yDiff, xDiff/10000) * Rad2Deg; result = Math.Round(Math.Abs(result), 1); return result; }
For tick charts the calculation won't work here, because x1 and x2 are based on DateTime objects.
Does anyone knows a trick to calculate the angle of a line correctly in tick charts?

Thanks in advance
Ingo :)

HellGhostEvocatorX
Posts: 80
Joined: 10 Feb 2022
Has thanked: 52 times
Been thanked: 11 times

Re: Angle of a line / Tick Data  [SOLVED]

Postby HellGhostEvocatorX » 23 Sep 2023

https://www.tradingcode.net/multicharts ... lume-tick/

maybe the link will help. Incorrect adjustment?

Or is Bars.Ticks what you are looking for?

My understanding of tickcharts is that a tick is always created when supply/demand match. After a certain time, the "sum of change" is displayed as a time/price bar. As a tick chart, the tick "bars" are drawn by the number of ticks that occur, so instead of time, you need the number of ticks for the "x-axis" (number of trades completed).
If Bars.Ticks doesn't work, the sum of Bars.DownTicks and Bars.UpTicks might be what you're looking for.

Without complete code, I can only assume since I don't work with tick charts myself.

lordongi
Posts: 29
Joined: 18 Dec 2017
Has thanked: 10 times
Been thanked: 3 times

Re: Angle of a line / Tick Data

Postby lordongi » 24 Sep 2023

Thank you HellGhostEvocatorX, that helped me a lot.


Return to “MultiCharts .NET”