Calculating the Angle / Linear Regression of a line

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10487 quote
    minmaxminmax
    Participant
    Average

    I’d like to be able to calculate the angle (linear regression?) of any line i.e. a moving average, a standard deviation

    For example.. if the angle of the Average[500] reaches X degrees positive/negative then buy/sell (means: don’t trade when it’s flat)

    What is the best way to calculate/code that?

    Regards

    Steve

    #10488 quote
    NicolasNicolas
    Keymaster
    Legend

    IMO it’s useless since angle degree depends of the height/width of your chart/computer screen. You’d better look at price percentage change over x periods, I think it’s more accurate 🙂

    #11606 quote
    smartinicksmartinick
    Participant
    New

    Just browsing the forum as i noticed this post… as i’m using ema-trend as a trade filter, i’m happy to share a guite simple code:

     

    if tradeema[1]>tradeema and tradeema[2]>tradeema[1]then
    ematrend = -1
    endif
    
    if tradeema[1]<tradeema and tradeema[2]< tradeema[1]then
    ematrend = 1
    endif

     

    this simply compares if the tradeema rises or falls within the last 2 bars.

    you could also check if the difference of tradeema[2] & tradeema[1] if positive but smaller than the diff of tradeema[1] and tradeema -> which would mean it’s getting steeper.

    getting a angle value is useless imho as there’s the need for a absolute x & y scale. but based on the difference you could use a treshold value to check if the slope is steep enough…

    Brgds, Martin.

    AlgoAlex thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Calculating the Angle / Linear Regression of a line


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
minmax @minmax Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by smartinicksmartinick
10 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/15/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...