Download MetaTrader 5
To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
strontiumDog
266
strontiumDog 2013.10.03 14:57 

Hello

Assuming I have an smaHandle piping in SMA values to my smaVals[] array, I need to find the angle of the trend over a specified number of bars in a zoom-friendly manner.

I've seen 

OBJ_TRENDBYANGLE

but it looks like it's geared towards price.  Does anyone know if there is a more general tool for calculating this in mql5?  As is already known

ATan(vertical height / horizontal length) * 180 / PI()

would give me the angle of the trend, but as the horizontal length and vertical height are different units, I'm stuck.  I've read somewhere else on the forum that it's not possible as such, but an equivalent would do it. 

Documentation on MQL5: Timeseries and Indicators Access / Bars
Documentation on MQL5: Timeseries and Indicators Access / Bars
  • www.mql5.com
Timeseries and Indicators Access / Bars - Documentation on MQL5
Alain Verleyen
Moderator
29640
Alain Verleyen 2013.10.03 15:56  
strontiumDog:

Hello

Assuming I have an smaHandle piping in SMA values to my smaVals[] array, I need to find the angle of the trend over a specified number of bars in a zoom-friendly manner.

I've seen 

OBJ_TRENDBYANGLE

but it looks like it's geared towards price.  Does anyone know if there is a more general tool for calculating this in mql5?  As is already known

ATan(vertical height / horizontal length) * 180 / PI()

would give me the angle of the trend, but as the horizontal length and vertical height are different units, I'm stuck.  I've read somewhere else on the forum that it's not possible as such, but an equivalent would do it. 

Maybe this code can help you ?
Simon Gniadkowski
Moderator
17975
Simon Gniadkowski 2013.10.03 16:08  
strontiumDog:

Hello

Assuming I have an smaHandle piping in SMA values to my smaVals[] array, I need to find the angle of the trend over a specified number of bars in a zoom-friendly manner.

You can't . . .  angles only work when you have the same units for the two lines that make an angle,  use a gradient or slope instead. 
Pasi Hakamaki
4060
Pasi Hakamaki 2013.10.03 18:31  
Maybe you could also try to use the linear regression of the SMA, just my suggestion.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
/
To add comments, please log in or register