Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change MACD Line color when it cross the Avg

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Change MACD Line color when it cross the Avg

    Hello,

    I am looking to change the macd line from lets say red to green when the macd line cross the macd avg. I want the macd line to stay green for the initial cross candle and then the two candles after. Once there has been 4 candles I want it to go back to red. Is this something that can be done easily?

    #2
    Hello durdcash,

    Thank you for your post.

    This should be possible without too much hassle. I suggest checking out the multi-colored plots reference sample here for an example of changing plot colors when certain conditions are met:
    If you are wanting it to stay green for a set number of candles, you will likely need to record the CurrentBar index when the crossover condition is met in a variable, then add a check if the new CurrentBar is greater than or equal to the saved bar index plus however many bars since the crossover and if so, change the plot to red again.

    Crossovers can be detected with CrossAbove() and CrossBelow():Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X