Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Plot Color for an Indicator in a Strategy

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

    Strategy Plot Color for an Indicator in a Strategy

    I have a strategy which adds a few indicators onto the chart when the strategy is loaded and enabled. I was able to direct the panel which the plot was directed to with the following commands in the Initialize section of the strategy:

    SceetoCLMacDaddy(true).Panel=1;
    Add( SceetoCLMacDaddy(true));

    The first line directs the named plot to a specific panel and the second line actually adds the
    indicator to the chart.

    My question is, is there a similar syntax for directing both the color of the particular indicator and the line type, in a manner similar to directing the plot panel. I've tried various combinations and none have worked so far. I know it is possible to manually change the color and type once it is on the chart but I'd like it to be correct as soon as it is added.

    If that is possible.

    Thanks

    DaveN

    #2
    Hello DaveN,
    Thanks for your post.

    Yes, you can do so. Please refer to the SampleMACrossover strategy that comes with NinjaTrader which further demonstrates how to color the plots.


    Code:
    SMA(Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Slow).Plots[0].Pen.Color = Color.Green;


    You can set the DashStyle via the Pen class itself.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      I'm sorry to be thick but when I search the help guiide I find no pen class. There is a plot class but I tried setting the style as I did the color and it doesn't work. The color setting works fine using the following command:

      EMA(Close, 3).Plots[5}.Pen.Color = Color.Magenta;

      but when I try the following:

      EMA(Close, 3).Plots[5].Pen.PlotStyle = PlotStyle.Dot;

      I get an error message referring me to CS1061, but when I look that up on the MSN error codes it doesn't appear to exist. What is the syntax I should be using to set the pen plotstyle to dots?

      Thanks
      DaveN

      Comment


        #4
        Hello DaveN,
        The Pen class is not documented in our help guide.You can find more information from here
        Defines an object used to draw lines and curves. This class cannot be inherited.


        If you try using the below code then are you able to get it work
        Code:
        EMA(3).Plots[0].Pen.DashStyle = DashStyle.Dot;
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Originally posted by daven View Post
          I'm sorry to be thick but when I search the help guiide I find no pen class. There is a plot class but I tried setting the style as I did the color and it doesn't work. The color setting works fine using the following command:

          EMA(Close, 3).Plots[5}.Pen.Color = Color.Magenta;

          but when I try the following:

          EMA(Close, 3).Plots[5].Pen.PlotStyle = PlotStyle.Dot;

          I get an error message referring me to CS1061, but when I look that up on the MSN error codes it doesn't appear to exist. What is the syntax I should be using to set the pen plotstyle to dots?

          Thanks
          DaveN
          Pen does not have a PlotStyle. Try DashStyle instead. You must use defined properties if you want to modify objects.

          Comment


            #6
            Thanks, I have it working now and it is making the indicator colored dotted lines. I appreciate the help.
            DaveN

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 01:00 AM
            0 responses
            1 view
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            27 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 04-23-2024, 09:53 PM
            2 responses
            74 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            193 views
            0 likes
            Last Post Hasadafa  
            Working...
            X