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 DanielTynera, Today, 01:14 AM
            0 responses
            2 views
            0 likes
            Last Post DanielTynera  
            Started by yertle, 04-18-2024, 08:38 AM
            9 responses
            40 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by techgetgame, Yesterday, 11:42 PM
            0 responses
            11 views
            0 likes
            Last Post techgetgame  
            Started by sephichapdson, Yesterday, 11:36 PM
            0 responses
            2 views
            0 likes
            Last Post sephichapdson  
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,615 views
            0 likes
            Last Post aligator  
            Working...
            X