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 a plot depending of it's value?

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

    Change color of a plot depending of it's value?

    How can I change the color of a plot depending of it's value?

    Example:

    //Long signal
    if (MyCalc)
    MyPlot[0] = 1

    //Short signal
    else if (MyCalc)
    MyPlot[0] = -1

    else
    MyPlot[0] = 0

    If the value of MyPlot is 1 i want it o be green, -1 I want it to be red. If there's no signal I just want to keep the color that is stated in AddPlot(Brushes.Grey, "MyPlot").

    Cheers,
    Christian

    #2
    Hello Christian,

    Thanks for your post.

    To change the color of the plot you would use PlotBrushes. Please see the helpguide: http://ninjatrader.com/support/helpG...lotbrushes.htm

    Example:

    //Long signal
    if (MyCalc)
    {
    MyPlot[0] = 1
    PlotBrushes[0][0] = Brushes.Green;
    }

    //Short signal
    else if (MyCalc)
    {
    MyPlot[0] = -1
    PlotBrushes[0][0] = Brushes.Red;
    }

    else
    MyPlot[0] = 0
    // leave to plot default grey color
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you, that works! Had to add a ";" though:

      if (MyCalc)
      {
      MyPlot[0] = 1;
      PlotBrushes[0][0] = Brushes.Green;
      }

      It only "paints" half of the "spike", it's not that important but if there's a simple solution...?

      Comment


        #4
        Hello chrille,

        Thanks for your reply.

        The code is only adding the Green or Red if the plot value is +1 or -1 and defaults to the grey color you assigned to the plot when the value does not equal either +1 or -1.

        You can try adding other conditions such as testing if the previous plot value [1] was equal to a +1 or a -1 and the current plot value[0] is equal to zero then you can assign the red or green plot brushes to color the return to zero.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello Paul, Do you have colour the plot indicator for Ninja trader 7 by any chance?

          Comment


            #6
            Hello 3pierre39,

            Thanks for your post and welcome to the NinjaTrader forums.

            No, I do not.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank you. It is an amazing tool. Thank you very much.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GLFX005, Today, 03:23 AM
              0 responses
              1 view
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              11 views
              0 likes
              Last Post XXtrader  
              Started by Waxavi, Today, 02:10 AM
              0 responses
              6 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              12 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Working...
              X