Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        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.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cls71, Today, 04:45 AM
            0 responses
            1 view
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            213 views
            1 like
            Last Post PaulMohn  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            4 responses
            544 views
            0 likes
            Last Post PaulMohn  
            Started by GLFX005, Today, 03:23 AM
            0 responses
            3 views
            0 likes
            Last Post GLFX005
            by GLFX005
             
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            12 views
            0 likes
            Last Post XXtrader  
            Working...
            X