Get MA indicator line color

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #186780 quote
    krogenkrogen
    Participant
    New

    Hi there,

    I’m trying to write script where it checks if the MA line color changes from one bar to the next. Is there a property or method to get the color of the MA line e.g. green for bullish and red for bearish?

    Thanks for any help!

    k

    #186797 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    MA = average[20,0](close)
    BullMA = MA > MA[1]
    BearMA = MA < MA[1]
    MAchange = (BullMA and BearMA[1]) or (BullMA[1] and BearMA)

    lines 2 and 3 retain the trend of the MA, while line 4 returns any change in direction (colour).

    #186801 quote
    krogenkrogen
    Participant
    New

    Thank you @robertogozzi!

    Something I don’t understand as I am new to this scriping language (though I have experience with JavaScript and C#)

    BearMA[1]

    Shouldn’t the above contain only a true or false value? How can you use it like an array?

    #186807 quote
    JSJS
    Participant
    Master
    MySma   = average[20,0](close)
    Rising  = MySma > MySma[1] AND MySma[1] < MySma[2]
    Falling = MySma < MySma[1] AND MySma[1] > MySma[2]
     
    if rising then 
     r = 0
     g = 255
    elsif falling then 
     r = 255
     g = 0
    endif 
     
    return mysma coloured(r,g,0)
    
    robertogozzi thanked this post
Viewing 4 posts - 1 through 4 (of 4 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

Get MA indicator line color


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
krogen @krogen Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by JSJS
4 years, 8 months ago.

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