• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    https://ninjatrader.com/support/help...drawobject.htm

    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 WHICKED, Yesterday, 09:03 PM
            1 response
            15 views
            0 likes
            Last Post Emma1
            by Emma1
             
            Started by oleotrim, Yesterday, 11:29 PM
            1 response
            10 views
            0 likes
            Last Post Emma1
            by Emma1
             
            Started by Heavyweight_Prop, Yesterday, 09:06 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_EricB  
            Started by saltminer, Yesterday, 05:49 PM
            0 responses
            10 views
            0 likes
            Last Post saltminer  
            Started by brunoviveiros, Yesterday, 05:32 PM
            0 responses
            6 views
            0 likes
            Last Post brunoviveiros  
            Working...
            X