(Relative) Angle of moving average

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #181586 quote
    eckaw
    Participant
    Veteran

    Hi all

    How would one code the following?

    – Angle of moving average > angle of moving average[1]

    I wonder if this approach would be interesting to look at combined with relative volume as an entry condition.

    #181589 quote
    phoentzs
    Participant
    Master

    Take a look at the topic “vectorial dax”. That could be something for you.

    #181590 quote
    JC_Bywan
    Moderator
    Master

    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])

    #181594 quote
    robertogozzi
    Moderator
    Master

    There 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)

    Sma   = average[20,0](close)
    Angle = (Sma - Sma[1]) / Sma[1]
    If Angle > Angle[1] Then
     .
     .
    Endif
    thanked this post
    #181597 quote
    robertogozzi
    Moderator
    Master

    I was writing while JC_Bywan was posting 🙂

    #181601 quote
    nonetheless
    Participant
    Master

    this is the code I use, adapted from Balmora’s Vectorial. Similar to above with added trig function

    //ANGLE
    ONCE Period1 = p1
    ONCE Period2 = p2
    EMA1 = ExponentialAverage[Period1](close)
    slope = (EMA1-EMA1[Period2]) / Period2
    ANGLE = (ATAN(slope)) 
    CB1 = ANGLE >= a1
    CS1 = ANGLE <= -a2
    #181603 quote
    murre87
    Participant
    Senior

    Do u use this as entrysignal?

    #181605 quote
    nonetheless
    Participant
    Master

    in conjunction with other indicators, yes. often it’s more of a filter on a higher TF

    #181623 quote
    murre87
    Participant
    Senior

    ju set P1 and P2 ur self?

    Also a1 and -a2?

    #181626 quote
    nonetheless
    Participant
    Master

    yes, 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

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

(Relative) Angle of moving average


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
eckaw @eckaw Participant
Summary

This topic contains 9 replies,
has 6 voices, and was last updated by nonetheless
4 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/14/2021
Status: Active
Attachments: No files
Logo Logo
Loading...