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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            80 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            40 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
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X