Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change Indicator Plot Color in a Strategy

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

    Change Indicator Plot Color in a Strategy

    I have an indicator with 4 plots , 3 of them are set to Transparent by default. I want to change the colors of the indicator Plot in my Strategy that uses the indicator. Please advice the best way to do that,

    I tried something to the effect of:

    Code:
            protected override void Initialize()
            {
    			Add(FlowStatsAverageAtTOD(sessionLookback));
    			
    			FlowStatsAverageAtTOD(sessionLookback).Plots[0].Pen = new Pen(Color.Blue);
                CalculateOnBarClose = true;
            }
    but that doesn't seem to work. Thanks

    #2
    Originally posted by newworldguy View Post
    I have an indicator with 4 plots , 3 of them are set to Transparent by default. I want to change the colors of the indicator Plot in my Strategy that uses the indicator. Please advice the best way to do that,

    I tried something to the effect of:

    Code:
            protected override void Initialize()
            {
                Add(FlowStatsAverageAtTOD(sessionLookback));
                
                FlowStatsAverageAtTOD(sessionLookback).Plots[0].Pen = new Pen(Color.Blue);
                CalculateOnBarClose = true;
            }
    but that doesn't seem to work. Thanks
    Code:
    FlowStatsAverageAtTOD(sessionLookback).Plots[0].Pen.Color = Color.Blue;
    Last edited by koganam; 05-18-2014, 10:53 AM.

    Comment


      #3
      Hello newworldguy,

      Thank you for your post.

      Koganam's response would work there for your indicator. Another option is to set the colors in the indicator as variables and then set them as you would any variable when calling the indicator method in your strategy: http://www.ninjatrader.com/support/f...ead.php?t=4977

      Comment


        #4
        Just wondering what is the semantic difference between:

        FlowStatsAverageAtTOD(sessionLookback).Plots[0].Pen = new Pen(Color.Blue);

        and:

        FlowStatsAverageAtTOD(sessionLookback).Plots[0].Pen.Color = Color.Blue;

        obviously only the latter works. especially because the former is recommended as an example in the documentation.

        Comment


          #5
          newworldguy, I'm not sure which part of the docs you refer to, would you mind clarifying? Our tip on adding indicators to strategies would outline the semantic needed as the second one - http://www.ninjatrader.com/support/f...ead.php?t=3228

          You don't want to create a new Pen object here, but modify the color property of the existing one.

          Comment


            #6
            I was referring to:

            Comment


              #7
              Thanks, will channel it to update.

              Comment


                #8
                can I add Plot to a new panel in a strategy, programatically?

                Comment


                  #9
                  You could be checking in this sample's approach for that - http://www.ninjatrader.com/support/f...ead.php?t=6651

                  Comment


                    #10
                    I would be happy to specify the panel within my indicator, is that possible? or alternatively, can I add the indicators to different panels programatically? thanks

                    Comment


                      #11
                      Yes, the tip on Adding indicator in would allow for the spec'ing of the panel to use as well. It would be for the complete indicator though, and not per plot.

                      Comment


                        #12
                        thanks. I like to use visual studio to write my code so I have added referenced to the dlls NT.Custom, NT. Core etc. and everything works fine but the StrategyPlot seems to be defined in another dll. Can you please point out which one?

                        Thanks,

                        Comment


                          #13
                          Those would not be part of any dll shipped, but custom indicators you have installed with the reference sample provided. Here we call dummy / placeholder indicators providing strategies with a way to set a plot value as natively they would not be able to.

                          Comment


                            #14
                            Change indicator color in strategy

                            Hello. What if I need to change indicator color in strategy OnBarUpdate()? So, only after some conditions indicator should change color.

                            Comment


                              #15
                              For that I would look into changing the PlotColors of your placeholder indicator instead of the Pen Color -

                              StrategyPlot(0).PlotColors[0][0]

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sjsj2732, Yesterday, 04:31 AM
                              0 responses
                              33 views
                              0 likes
                              Last Post sjsj2732  
                              Started by NullPointStrategies, 03-13-2026, 05:17 AM
                              0 responses
                              286 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              285 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              133 views
                              1 like
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              91 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Working...
                              X