(Relative) Angle of moving average
Forums › ProRealTime English forum › ProOrder support › (Relative) Angle of moving average
- This topic has 9 replies, 6 voices, and was last updated 2 years ago by nonetheless.
-
-
11/14/2021 at 4:33 PM #18158611/14/2021 at 5:07 PM #18158911/14/2021 at 5:10 PM #181590
Hi,
If your moving average name is “ma”, its angle being higher than it was at previous candle is equivalent to a bigger vertical step for same horizontal step, which you can store in a boolean variable true=1 or false=0 to use within your code:
risingma = (ma-ma[1]>ma[1]-ma[2])
11/14/2021 at 5:28 PM #181594There are many ways to (try to) define angles:
https://www.prorealcode.com/reply/158329/
Let’s say we want to use (SMA (new) – SMA (old)) / SMA (old)
123456Sma = average[20,0](close)Angle = (Sma - Sma[1]) / Sma[1]If Angle > Angle[1] Then..Endif1 user thanked author for this post.
11/14/2021 at 5:30 PM #181597I was writing while JC_Bywan was posting 🙂
11/14/2021 at 5:57 PM #181601this is the code I use, adapted from Balmora’s Vectorial. Similar to above with added trig function
12345678//ANGLEONCE Period1 = p1ONCE Period2 = p2EMA1 = ExponentialAverage[Period1](close)slope = (EMA1-EMA1[Period2]) / Period2ANGLE = (ATAN(slope))CB1 = ANGLE >= a1CS1 = ANGLE <= -a211/14/2021 at 6:22 PM #18160311/14/2021 at 6:31 PM #181605in conjunction with other indicators, yes. often it’s more of a filter on a higher TF
11/15/2021 at 11:25 AM #18162311/15/2021 at 11:45 AM #181626yes, all variables to be optimized for whatever TF you want to use.
the angle of a 5min MA will obviously be completely different from a 1 hour MA
-
AuthorPosts
Find exclusive trading pro-tools on