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

Two Draw.Line questions

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

    Two Draw.Line questions

    Hi,

    I'm wondering is there a way to write draw over the close of a bar and re-colour it?
    I'm basically looking for an equivalent to BarBrushes[0] & CandleOutlineBrushes[0] except just for the close line.

    I can do it with a dot, but I don't know how to do it with a line.
    Code:
    Draw.Dot(this, "Bull" + CurrentBar, true, 0, Close[0], BuyerCloseBrush);
    The second thing I'd like to know is how to adjust the int outline Width on a Draw.Text. I'm not entering the arguments correctly.
    Code:
    if ((Open[0] == Close[0]))
    Draw.Text(this, "Doji" + CurrentBar, false, "Doji".ToString(), 0, High[0], 80, Brushes.PeachPuff, MyFont, TextAlignment.Center, Brushes.DodgerBlue, Brushes.Black,99);
    I've tried adding the extra arguments to get access to int outlineWidth, but I keep getting it wrong. How should I add the arguments? Thank you!
    Click image for larger version  Name:	Outline Width1.png Views:	0 Size:	23.1 KB ID:	1229224
    Last edited by Bob-Habanai; 12-29-2022, 04:10 AM.

    #2
    Hello Bob-Habanai,

    Draw.Line() draws from the center of a bar to the center of another bar. You could draw a line at the bar close price from the current bar to the previous bar.

    Or you could choose to custom render the line over the current bar's close.

    Below is a link to a script that does custom rendering and will save you some time on finding some of the bar location coordinates.
    This is a conversion of the Spread Indicator with Candlesticks. Please contact the original author for any questions or comments.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thank you for all your help. The custom rendering is going to take me a while to learn, and I will stick at it,
      but I was wondering if DateTime might be another way to do it?
      Is there a way to say

      Draw.Line(this, "Close Line" + CurrentBar, true, Datetime = 1minute30seconds before current bar, Close[0], Datetime = 1minute30seconds after current bar, Close[0], Plots[0].Brush, Plots[0].DashStyleHelper, (int) Plots[0].Width);

      Thanks

      Comment


        #4
        Originally posted by Bob-Habanai View Post
        Hi,

        I'm wondering is there a way to write draw over the close of a bar and re-colour it?
        I'm basically looking for an equivalent to BarBrushes[0] & CandleOutlineBrushes[0] except just for the close line.

        I can do it with a dot, but I don't know how to do it with a line.
        Code:
        Draw.Dot(this, "Bull" + CurrentBar, true, 0, Close[0], BuyerCloseBrush);
        The second thing I'd like to know is how to adjust the int outline Width on a Draw.Text. I'm not entering the arguments correctly.
        Code:
        if ((Open[0] == Close[0]))
        Draw.Text(this, "Doji" + CurrentBar, false, "Doji".ToString(), 0, High[0], 80, Brushes.PeachPuff, MyFont, TextAlignment.Center, Brushes.DodgerBlue, Brushes.Black,99);
        I've tried adding the extra arguments to get access to int outlineWidth, but I keep getting it wrong. How should I add the arguments? Thank you!
        Is this what you are looking for? If so use the regular Plots for Close values.

        Click image for larger version

Name:	hash example.png
Views:	169
Size:	23.0 KB
ID:	1229514


        For the Outline width:

        Code:
        Text text = Draw.Text(this,"test","Outline",0,High[0]);
                        text.OutlineStroke.Brush = Brushes.Yellow;
                        text.OutlineStroke.Width = 3;​
        Attached Files
        Last edited by Borgen; 01-01-2023, 04:02 AM.

        Comment


          #5
          Hello Bob-Habanai,

          It is fine to provide dates for the bar anchors to Draw.Line(), but it will still draw from the middle of a bar to the middle of another.

          Borgen has an interesting solution using the Hash plot style with a plot added with AddPlot() and the value set to the Close[0].
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks Borgen,

            I'm all sorted now.

            Much appreciated!

            Originally posted by Borgen View Post

            Is this what you are looking for? If so use the regular Plots for Close values.

            Click image for larger version  Name:	hash example.png Views:	61 Size:	23.0 KB ID:	1229514


            For the Outline width:

            Code:
            Text text = Draw.Text(this,"test","Outline",0,High[0]);
            text.OutlineStroke.Brush = Brushes.Yellow;
            text.OutlineStroke.Width = 3;​
            Last edited by Bob-Habanai; 02-02-2023, 12:51 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by traderqz, Today, 12:06 AM
            2 responses
            3 views
            0 likes
            Last Post traderqz  
            Started by RideMe, 04-07-2024, 04:54 PM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by f.saeidi, Today, 08:13 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by DavidHP, Today, 07:56 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by kujista, Today, 06:23 AM
            3 responses
            11 views
            0 likes
            Last Post kujista
            by kujista
             
            Working...
            X