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 lightsun47, Today, 03:51 PM
            0 responses
            5 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            10 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            46 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            10 views
            0 likes
            Last Post port119
            by port119
             
            Working...
            X