Hi,
I am trying to figure out slope degree calculation ,is it possible to calculate correctly.
i am using following data
p1= 1.17657 p2= 1.17854 angle(as told in mt5 chart) = 55 or 56
d1=D'2017.12.15 01:11' d2=D'2017.12.15 12:31
i have tried inverse tan or MathArctan.
I am not getting expected results any idea plz.
You are not the first. Please see
no working example found did lot of searching mql specific.
no working example found did lot of searching mql specific.
Well in short, you can not. Change your chart size and the slope will change. Not sure if you can solve your problem using another method. But slope or angle calculation based on chart is useless.
Change your chart size/scale, the slope will not change, the apparent angle will.
If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 2
you can use:
point value * window * timeframe coefficient
point value is minimum price change for example for eurusd is .00001
window is number of candles that you want to get their slope
time frame coefficient is 1 for 1 minute timeframe and 2 for 2 minute timeframe and ....
this python function calculate slope for given data (eg:moving average)
import math
def slope(data, window,point_value=.00001,time_frame_coefficient=1): s = pd.Series(index=data.index) for i in range(window, len(data.index)): m = (data.iloc[i] - data.iloc[i-window])/(window*point_value*time_frame_coefficient) atan = math.atan(m) degree = math.degrees(atan) s.iloc[i] = degree return s
Thanks shayan,
I did a manual calculation to see if I got the sums right.
Hourly bars on gold starting from 2022.02.23 11:00 XAUUSD pointvalue = .01 price low rounded to for convenience sake 1890.00 to price high 24 bars later 1974.00 (8400 point rise)
(.01 * 24bars * 60minutes = 14.4)
(.01 * 9bars * 60minutes = 5.4 )
XAUUSD 8400 points up over 24 hourly bars = 8400*.01 = 84 / 14.4 = 5.8333 MathArcTan(5.8333)=80°
XAUUSD 8400 points down over 9 hourly bars = 8400*.01 = 84 / 5.4 = 15.555 MathArcTan(15.555)=86°
https://www.math.net/calculators/arctan

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to figure out slope degree calculation ,is it possible to calculate correctly.
i am using following data
p1= 1.17657 p2= 1.17854 angle(as told in mt5 chart) = 55 or 56
d1=D'2017.12.15 01:11' d2=D'2017.12.15 12:31
i have tried inverse tan or MathArctan.
I am not getting expected results any idea plz.