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 Pen color, on the fly?

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

    Change Pen color, on the fly?

    Hi,

    I've been trying something like the following:

    Plots[0].Pen = new Pen(color, 4);
    HA_Plot1.Set(Close[0]);

    ... to change the color of the plot based on certain values. I'm not getting a compile error for doing this, but the setting of the pen color is being ignored completely.

    Thoughts ? I've looked at the SampleMultiColorPlot, but that uses multiple Plots. I'd rather use multiple pens instead... possible?


    Thanks.

    TazaTek

    #2
    Unfortunately this is not supported.

    Comment


      #3
      Hi there,
      I am not sure if this is possible but in manual I found this piece of code:
      // Initialize method of a custom indicator
      protected override void Initialize()
      {
      // Plots are added to the Plots collection in order
      Add(new Plot(Color.Orange, "Plot1")); // Stored in Plots[0]
      Add(new Plot(Color.Blue, "Plot2")); // Stored in Plots[1]
      }

      // Dynamically change the primary plot's color based on the indicator value
      protected override void OnBarUpdate()
      {
      if (Value[0] > 100)
      Plots[0].Pen = new Pen(Color.Blue);
      else
      Plots[0].Pen = new Pen(Color.Red);
      }

      What exactly is this doing? I understood it as tazatek described...

      Comment


        #4
        Just changes the color from blue to red of the primary plot of an indicator.
        RayNinjaTrader Customer Service

        Comment


          #5
          I am trying to do the same but getting an error message when trying to compile; "Does not contain a definition for "Pen" My code:


          {
          Plot0.Set(VOLMA(14)[0]);
          if(CurrentBar < 1) return;
          if (VOLMA(14)[0] > 100)
          Plot0.Pen = new Pen(Color.Red);
          else
          Plot0.Pen = new Pen(Color.White);
          }


          Any suggestion?

          Comment


            #6
            Hello Pete77,

            Thanks for your question.

            Plot0 in your context looks to be the associated DataSeries object, not to be confused with your actual Plot.

            You may refer to the publicly available documentation below for syntax on changing a Plot's color by pen and with PlotColors.

            Plots Collection (example for changing color by pen is included within) - https://ninjatrader.com/support/help.../nt7/plots.htm

            PlotColors - https://ninjatrader.com/support/help...plotcolors.htm

            Please let us know if you have any additional questions.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            4 responses
            21 views
            0 likes
            Last Post alifarahani  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PhillT, Today, 02:16 PM
            2 responses
            7 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Started by Kaledus, Today, 01:29 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X