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

Setting Dash.Style and Width on custom Plots

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

    Setting Dash.Style and Width on custom Plots

    Hello,

    i have created a custom indicator that shows me some specific price data. (see screenshot) Therefore i used the following statement in the Initialize-method:

    Code:
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Square, "ShortSL"));
    As default value i want to set:
    - the dash-style to: Dash
    - the width to: 2

    I've already ready read the following article in the "Tips"-section, but it didn't helped. http://www.ninjatrader-support2.com/...ead.php?t=3228

    It would be very nice if someone could help.

    Thanks!
    Attached Files

    #2
    Is this from within an indicator? If you want to do it from an indicator you just do it from the Add() method itself.


    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      yes, it is from within an indicator. I checked the 2links from the help guide and now i am one step closer to my solution, but not finished yet.
      With the modified code the thickness of the the Plot is set to "2", but where do i have to set my default DashStyle? ("DashStyle = Dash")?

      the modified code from my indicator:
      Code:
      Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Square, "ShortSL"));

      Comment


        #4
        Change the PlotStyle to Dash. That is what you want to do.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          That doesn't work. I will try to explain my needs in another way.

          In the Add()-method it is only possible to define the Color, name, PlotStyle of the Plot and create a new Pen (if needed).

          But, where can I set up the default "Dash Style" (see pic 1) in the code? Normally, when I create a new Plot it is set to "Solid" (see pic 2), but i would like to have it (per default) as "Dash" (see pic 3).

          Here is the code snippet:
          Code:
          protected override void Initialize()
          {
          Add(new Plot(new Pen(Color.Green, 2), PlotStyle.Square, "LongSL"));
          Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Square, "ShortSL"));
          CalculateOnBarClose    = true;
          Overlay                = true;
          PriceTypeSupported    = false;
          }
          Attached Files

          Comment


            #6
            Plots[0].DashStyle

            Try that.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              Plots[0].DashStyle

              Try that.

              ok, this works! thanks a lot!!

              Comment


                #8
                Setting the DashStyle in custom indicators

                Hi,
                I was looking for a way to set the dash style and width for the 3 lines I am plotting in my custom indicator when I came across your post. First I created a region of code where I defined 3 seperate Pens. Secondly, I configured each pen with its own colour, dashstyle and width setting. Finally I added the pen within the Plot paramaters. The result is that the dashstyle and width setting seeting The coding I did it with is below:


                #region Pens
                Pen CurOpenPen=
                new Pen(Color.SlateGray);
                CurOpenPen.DashStyle = DashStyle.DashDotDot;
                CurOpenPen.Width=
                3;


                Pen PrevHighPen= new Pen(Color.Blue);
                PrevHighPen.DashStyle = DashStyle.DashDot;
                PrevHighPen.Width=
                2;


                Pen PrevLowPen= new Pen(Color.Tomato);
                PrevLowPen.DashStyle = DashStyle.DashDot;
                PrevLowPen.Width=
                2;


                Pen PrevClosePen= new Pen(Color.Black);
                PrevClosePen.DashStyle = DashStyle.DashDot;
                PrevClosePen.Width=
                3;
                #endregion

                #region plots

                Add(new Plot(PrevHighPen, PlotStyle.Line, "PrevHigh"));
                Add(
                new Plot(PrevLowPen, PlotStyle.Line, "PrevLow"));
                Add(
                new Plot(PrevClosePen, PlotStyle.Line, "PrevClose"));
                Add(
                new Plot(CurOpenPen, PlotStyle.Line, "CurOpen"));
                #endregion

                Hope this helps!
                dowtrader
                London, UK
                Last edited by dowtrader; 08-12-2009, 09:21 AM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by f.saeidi, Today, 12:14 PM
                3 responses
                7 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Russ Moreland, Today, 12:54 PM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by philmg, Today, 12:55 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by TradeForge, 04-19-2024, 02:09 AM
                2 responses
                31 views
                0 likes
                Last Post TradeForge  
                Started by aprilfool, 12-03-2022, 03:01 PM
                3 responses
                327 views
                0 likes
                Last Post NinjaTrader_Adrian  
                Working...
                X