I want to compare the angle of lines drawn (between 2 points) in different charts of different instruments. I am aware of Tomasz post regarding anisotropic charts but if scaling and zoom level are equal for every chart then is it possible?
I mean there must be some way, Right? If I can see it then I should be able to determine it programmatically. Does not have to be perfect but must be COMPARABLE.
I tried something like this below but it is not comparable. It works in some instances and but not reliable.
ok agreed. Let me ask my question in a different way. is there a way to compare the slope of the lines of below chart such that one can arrive at a determination that lineChart3>lineChart1>lineChart2. All three charts are of the same time frame and same zoom level (number of bars visible is equal)
The code in your original post does not calculate an "angle", but it does appear to calculate the average % Return per Bar between points 1 and 2, and it seems to me that such a value should achieve your stated goal. However, you said that it was "unreliable", so perhaps you need to post your complete code along with an example of it not working as desired.
Well the code is as I posted in my original post. It sometimes fails to compare lines from different instruments. It returns greater values for angleOrSlopeOrWhatever , sometimes, for the lines that are visually flatter. Hence I am unable to rely on it.
@AlgoEnthusiast yes, as I look at your charts I see you are comparing a different number of bars so a simple Rate-of-Change comparison is inadequate. But I would suggest debugging your code (my personal preference is to break down each variable in an Explore and confirm it is calculating what is intended).
The code that you posted will not run, because the variables baRef1 (should be barRef1, perhaps?), barRef2, PriceP1, PriceP2 are all UNDEFINED.
Also, saying something like this:
It sometimes fails to compare lines from different instruments.
Is entirely useless. Nobody here is going to keep experimenting with your code until they find a pair of instruments where your code breaks. You need to provide EXAMPLES. You should probably also review: How do I debug my formula?
@AlgoEnthusiast - Rate of change works. What you are missing is that on chart whenever line is flatter or not depends on zoom factor (both X and Y zoom factors). Rate of change on the other hand is giving you number (percentage rate of change over specified number of bars) that does NOT depend on zoom factors.