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

Presetting Plots in Indicator

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

    Presetting Plots in Indicator

    I have a set of plots which I will update the values for each day before the market opens. Right now they are all lines and I would like to make one of them dots instead, to differentiate this particular plot from the others. I tried adding a PlotStyle statement to the indicator and it doesn't work. It seems there is a limit on how many modifications one can include in a plot statement. I'm including the code below that doesn't change the plot statement. Is there another way to do this (besides the manual way which I know works) but I'm trying to learn how to modify plots in indicators programmatically. I want the last plot (the fifth plot) to be dots instead of a line.
    Thanks

    protected override void Initialize()
    {
    Add(new Plot(new Pen(Color.DodgerBlue, 3), "BP_Low"));
    Add(new Plot(new Pen(Color.DodgerBlue, 3), "BP_High"));
    Add(new Plot(new Pen(Color.Magenta, 3), "SP_Low"));
    Add(new Plot(new Pen(Color.Magenta, 3), "SP_High"));
    Add(new Plot(new Pen( Color.Chartreuse, 3), "PitBull_MovAvg"));
    Plots[4].PlotStyle = PlotStyle.Dot;

    #2
    Did you reapply the indicator fresh after compiling the code modifications in?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes. I took the indicator completely off the chart, reapplied it and filled in the daily values fresh. I have four lines on the chart (the first four) properly colored and in the correct location. The fifth line (designated Plots[4] in the code) doesn't show up at all. If I remove the last definition line in the initialize section (Plots[4].PlotStyle = PlotStyle.Dot; ) meaning I comment it out, the fifth line shows up in the right location, in the right color, as a line.

      Comment


        #4
        Daven, sorry I missed in the first post you were using the Pen object for the Plots, then you would need to use DashStyle.Dot -

        Code:
         
        Plots[0].Pen.DashStyle = DashStyle.Dot;
        BertrandNinjaTrader Customer Service

        Comment


          #5
          That did the trick. Is there anyway I can add a pen size statement to the code to make the dots bigger? I tried changing them manually on the chart and they seem to be stuck at size 1?
          Thanks a bunch for your help.
          DaveN

          Comment


            #6
            You're welcome, you can add for example this to set the Pen width -

            Code:
             
            Plots[4].Pen.Width = 5;
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Worked great. Thanks for your help Bertrand. Have a great weekend.
              DaveN

              Comment


                #8
                Thanks, have a good weekend, too!
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by junkone, Today, 11:37 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by frankthearm, Yesterday, 09:08 AM
                11 responses
                41 views
                0 likes
                Last Post frankthearm  
                Started by quantismo, 04-17-2024, 05:13 PM
                5 responses
                35 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by proptrade13, Today, 11:06 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by love2code2trade, 04-17-2024, 01:45 PM
                4 responses
                34 views
                0 likes
                Last Post love2code2trade  
                Working...
                X