Determine if MA is sloping up or down

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #187045 quote
    krogen
    Participant
    New

    Hi again,

    I use a for loop to loop through the bars and determine if a 50 MA is sloping up or down. Is there an easier way to do this? Perhaps a built in function?

    I’m sorry I just can’t find it!

    k

    #187047 quote
    JS
    Participant
    Senior

    Hi @krogen

    You can make a indicator for this for example with colors.

     

    ma = average[50](Close)
    slope = ma - ma[1]
    
    
    if slope > 0 then
    if slope > slope[1] then
    g = 255
    r = 0
    elsif slope < slope[1] then
    g = 200
    r = 0
    endif
    elsif slope < 0 then
    if slope < slope[1] then
    r = 255
    g = 0
    elsif slope > slope[1] then
    r = 200
    g = 0
    endif
    endif
    
    return slope coloured(r, g, 10) style(histogram, 1)
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Determine if MA is sloping up or down


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
krogen @krogen Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JS
4 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/30/2022
Status: Active
Attachments: No files
Logo Logo
Loading...