Angle of MA lines

 
Hi all,

Can anyone help me with finding out the angle (in degrees) of Moving Average lines (or any other lines for that matter).

I basically want to know the angle that it makes from say one day to another, or from one hour to another. And I'd like to build a strategy based on whether the angle is steep or flat.

Does anyone have an idea or even sample code?

thanks
 
Hi all,

Can anyone help me with finding out the angle (in degrees) of Moving Average lines (or any other lines for that matter).

I basically want to know the angle that it makes from say one day to another, or from one hour to another. And I'd like to build a strategy based on whether the angle is steep or flat.

Does anyone have an idea or even sample code?

thanks

From geometry we know that an angle of such triangle you are describing is simply a tangent.
So try this:
double pipsec =  MathTan((iMA(i) - iMA(i+x)) / (Time[i+x]-Time[i]));   // To get a Tangent of Angle Pips/Sec.


x= A number of bars into the past.
For further calculation or display there is no need to convert Tangent to Degrees unless you must.

 
Hi all,

Can anyone help me with finding out the angle (in degrees) of Moving Average lines (or any other lines for that matter).

I basically want to know the angle that it makes from say one day to another, or from one hour to another. And I'd like to build a strategy based on whether the angle is steep or flat.

Does anyone have an idea or even sample code?

thanks

From geometry we know that an angle of such triangle you are describing is simply a tangent.
So try this:
double pipsec =  MathTan((iMA(i) - iMA(i+x)) / (Time[i+x]-Time[i]));   // To get a Tangent of Angle Pips/Sec.


x= A number of bars into the past.
For further calculation or display there is no need to convert Tangent to Degrees unless you must.



I have been interested in determining angle as well, however, I don't think "time" is a good choice, as it will yeld a different angle (for the same pip rage) for different times... what is "standard" is the actual chart (pixel) distance that makes up each time interval (5M, 15M, etc.). And even at that, the range changes based upon the price range of the chart for how many pips are represented by eah horz. grid.

I think to be accurate for angle, across all time frames ... one needs to know how many pips make a horz. grid... and then to (somehow) determine a simular distance for the vertical grid... possibly using a 45' degree line to make the measurement (horz. and vert. distance would need to be equal to get a 45' line).

Also, I beleive the Tangent product in expressed in Radians... not degrees... But I may be mistaken.

Any thoughts?
-charliev
 

I think to be accurate for angle, across all time frames ... one needs to know how many pips make a horz. grid... and then to (somehow) determine a simular distance for the vertical grid... possibly using a 45' degree line to make the measurement (horz. and vert. distance would need to be equal to get a 45' line).

Also, I beleive the Tangent product in expressed in Radians... not degrees... But I may be mistaken.

Any thoughts?
-charliev

Well,
You are mixing the Mathematic/Geometry with a Visualization.

The time is constant and is absolute as independent variable therefore it is proper horizontal value of a graph.
The pip value is also constant at specific symbol as dependent variable therefore, it is proper vertical value of a graph.
Therefore, Pips/Time is proper expression for the tangent of an angle.

For purpose of calculation the tangent remains constant regardless of time frame because Time[i] and Pips i.e High[i] are both constant in M1 as well as H1. There is no change in tangent by switching from M1 to H1 and back.

Of course you must compensate for shift: i.e. M1 time = Time[i of M1=iBarShift(symbol,M1,Time[i of H1])]; to find absolute M1 time and conversely H1 time.

So the tangent of an angle (pips/time) calculated in M1 can be used in, lets say H1 or D1.

However, the visualization is another matter.
If you draw two trendlines (p1/t1 - p2/t2) and (p3/t3 - p4/t4) they will have constant tangent of an angle to each other regardless of display in M1 or H1 but they may look different on the screen.

That should not fool you because the visualization has noting to do with real mathematics or geometry.

The visualization is simply a distortion of the reality.

The FX market is simply function of $/time or as we Americans say: "Time is money"!
 

I think to be accurate for angle, across all time frames ... one needs to know how many pips make a horz. grid... and then to (somehow) determine a simular distance for the vertical grid... possibly using a 45' degree line to make the measurement (horz. and vert. distance would need to be equal to get a 45' line).

Also, I beleive the Tangent product in expressed in Radians... not degrees... But I may be mistaken.

Any thoughts?
-charliev

Well,
You are mixing the Mathematic/Geometry with a Visualization.

The time is constant and is absolute as independent variable therefore it is proper horizontal value of a graph.
The pip value is also constant at specific symbol as dependent variable therefore, it is proper vertical value of a graph.
Therefore, Pips/Time is proper expression for the tangent of an angle.

For purpose of calculation the tangent remains constant regardless of time frame because Time[i] and Pips i.e High[i] are both constant in M1 as well as H1. There is no change in tangent by switching from M1 to H1 and back.

Of course you must compensate for shift: i.e. M1 time = Time[i of M1=iBarShift(symbol,M1,Time[i of H1])]; to find absolute M1 time and conversely H1 time.

So the tangent of an angle (pips/time) calculated in M1 can be used in, lets say H1 or D1.

However, the visualization is another matter.
If you draw two trendlines (p1/t1 - p2/t2) and (p3/t3 - p4/t4) they will have constant tangent of an angle to each other regardless of display in M1 or H1 but they may look different on the screen.

That should not fool you because the visualization has noting to do with real mathematics or geometry.

The visualization is simply a distortion of the reality.

The FX market is simply function of $/time or as we Americans say: "Time is money"!


Thats a great explaination, but don't we base our entries on visual information? For a particular indicator that uses angle, we look at that visual info, and enter if it meets a certain visual criteria.

Your formula is very helpful, I'm going to apply it to my indicator and see what it produces for an angle. Thanks for the reply!

-charliev
 

Thats a great explaination, but don't we base our entries on visual information?

Yes we do!
However, it does not matter what you see because a distorted view will not influence your trading strategy.
Think of it this way:
The chart is $/time grid with certain aspect ratio. As long as the aspect ratio is 1:1 then you have undistorted view. So the distortion is caused by aspect ratio [not] by change of drawn points on the $/time grid, they remain constant.

Therefore, when you draw your strategy on the chart you are connecting $/time grid coordinates by eyeballing data provided by the market having same grid values. Once you draw your trendline based on your strategy between two points you have created tangent of an angle between $ and time. Taking this tangent and conversely multiplying it by a future time will give you $ amount at that time. Please notice that change in an aspect ratio will not change the outcome of your charting.

For a particular indicator that uses angle, we look at that visual info, and enter if it meets a certain visual criteria.


So who cares if 10' at aspect ratio 1:1 look like 20' at aspect ratio 2:1? Behind all that angular distortion is a tangent which is constant representing your visual strategy base on connecting two candle points to get unknown point in the future based on linear interpolation.

Some time ago, I have proposed to Slawa to implement trend-sign-function (a wave) in addition to the linear-trendline-function so you could predict future $ value based on ripple, frequency or cycle of time which would be more accurate prediction because market data is a sum of cycles and its harmonic created by traders allover the world who are all synchronized by use of the same time frames M1,M5,M15,M30,H1,H4.................
Please notice that wave contains both BID && ASK values where line contains only BID || ASK valu.
Reason: