| / | Forum |
|
aspdeveloper
2007.02.13 17:40
Hi there,
How can I get the angle of a moving average which is plotted on a chart? For example: I have 2 to 3 moving averages plotted on my charts. Based on the angle (f.e. 60 degrees) I have an indicator on how strong the current uptrend is. Should I calculate the angle myself, based on the MA-values of the f.e. last 10 candles, or should I use the ObjectGet()-function? I tried the latter, but you have to specify a name, and since all my MA's have the same name (and I don't see how I can change them), there's nothing coming out ... (they're actually the same MA's, but based on close, high and low prices). Any help would be very much appreciated! Thanks in advance. Greetingz, Koen. |
|
Displaying of Support/Resistance Levels The article deals with detecting and indicating Support/Resistance Levels in the MetaTrader 4 program. The convenient and universal indicator is based on a simple algorithm. The article also tackles such a useful topic as creation of a simple indicator that can display results from different timeframes in one workspace. |
|
JosTheelen
2007.02.13 19:42
The angle depends on how much time you have on the horizontal axis. Suppose your
chart shows 2 days and you changes that to 1 day, the angle will become smaller.
So I suggest you don't use an angle, but something like "average difference
in pips per timeframe". That means: take the difference in value from MA1
and MA2 and divide it by the number of timeframes between the moment the MA's intersected
and the moment you want the angle.
|
|
aspdeveloper
2007.02.14 01:02
Thanks for the suggestion!!! Sounds good ... in fact, I already have something working!
But it needs a little tweaking ...
Greetingz, Koen. |
33759 |
Rosh
2007.02.14 11:05
You cannot measure a corner of an inclination of a straight line on the schedule
because have different units - the Price and Time. It is possible to measure only
similar with similar (like to like). In this case you try to measure a corner of
an inclination of a straight line on the schedule, expressed through pixels. You
can is authentic measure only speed of change of the price in terms of Point unit
for a Time unit.
|
|
DxdCn
2007.04.05 04:02
Gann Fan Lines of Gann Fan are built at different angles !!
MT can supply Angle function based on screen pixels (trans from two values and two times coodinates). Since Angle is more good for people to watch. Like: MathArctan(MathTan( ((price1-price2)/(WindowPriceMax()- WindowPriceMin())) / ((shift2-shift1)/WindowBarsPerChart()) )) *180/3.14 |
|
wheel_of_fire
2007.04.05 17:38
DxdCn,
I completely agree with you. Angles matter and they are used all the time. I'm interested in the formula you posted. I've been getting the angle with the following formula: (((MathArctan(line_slope/100))*(180/3.14159))*angle_factor); Slope is calculated in another function. Angle_factor controls for the format of the yen. Anyway, it gets close but it's still not right. When I put your formula instead, I get a divide by zero error in the strategy tester. Is this because the window functions don't work within the tester or did I do something wrong? Peace. |
33759 |
Rosh
2007.04.05 17:42
Let see Testing Features and Limits in MetaTrader 4 and will view there
|
|
wheel_of_fire
2007.04.05 17:56
Thanks, Rosh.
|
33759 |
Rosh
2007.04.05 18:51
You're welcome.
|
|
DxdCn
2007.04.06 10:52
Note : based on screen pixels !!! dx,dy should be in same unit,best trans to screen
pixels.
MathArctan(MathTan( ((price1-price2)/(WindowPriceMax()- WindowPriceMin())) / ((shift2-shift1)/WindowBarsPerChart()) )) *180/3.14 divide by zero error ? check (shift2-shift1) should not equal ZERO before calculating. I test them on newest version 203. I do not test them when testing EA. |
|
wheel_of_fire
2007.04.11 21:17
DxdCn,
I want to give you my deepest appreciation for the formula you shared. I didn't respond earlier because I had to finish getting my EA together. Works like a charm. Peace and goodwill.--The Wheel of Fire |