Announcement

Collapse
No announcement yet.

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:	218
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 cmoran13, 04-16-2026, 01:02 PM
            0 responses
            51 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            31 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            165 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            100 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            160 views
            2 likes
            Last Post CaptainJack  
            Working...
            X