Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

change color of line based on indicator

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

    change color of line based on indicator

    hi,
    running indicator 1, i would like to change the colors of the lines (painted from indicator 1), based on the values from indicator 2.
    i assume it is possible, but how can this be done?
    thx

    #2
    Hi Tradexxx, thanks for your post.

    If indicator 2 has a public plot or Series object then you can make an instance of indicator 2 in indicator 1. See the SampleMACrossover as an example. That strategy initializes two SMA indicators. I would recommend using RemoveDrawObject() to remove the old line and re-draw it with a different color.


    Please let me know if I can assist any further.

    Comment


      #3
      hello ChrisL, thank you for your post.

      i don't understand what you mean by this.
      imagine indicator 1 is ZIGZAG indicator.
      and indicator 2 is MACD.
      i would like to color the lines from ZIGZAG depending on result of MACD.
      something like MACD Diff < 0 then draw ZIGZAG red and in case MACD Diff > 0 then draw in green.
      is this possible?
      why do i need to remove DrawObject?
      thank you
      Last edited by Tradexxx; 03-27-2020, 12:03 AM.

      Comment


        #4
        Hi Tradexxx, thanks for your patience.

        The ZigZag indicator would be a little more difficult to manipulate because its Value[] array for the plot is sparse (it gets updates at random points in the data). One could change the back brush of the chart, but It would take a bit more investigation to find how the ZigZag plot itself (specifically PlotBrushes) can be changed based on this condition.

        I've attached an example for review.

        Attached Files

        Comment


          #5
          Hi Chris,
          thank you for your post.
          i saw that coloring the background by creating a normal indicator is working fine.
          than i added zigzag and recognice it's not working.
          for me, the print is ok. but unfortunately i don't have enough programming knowledge to proceed here...
          if any of you has any idea, i'll be happy to proceed......
          thank you

          Comment


            #6
            Hi Tradexxx, thanks for the follow up.

            I noticed in the Miscellaneous region of the code OnRender is being used. So the indicator is drawing with the DX brush directly. One would need to find a valid index with PlotBrushes[0].Get(index) and change the color that way for a variable ZigZag brush.

            Please let me know if I can assist any further.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            649 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X