Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Line Usage

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

    Draw.Line Usage

    Refer to the image below. How do I use the Draw.Line object to draw a line from the current High[0](i.e. point A) to High[x] (i.e. point B). My current code is drawing horizontal lines that runs through the entire screen (see code below).

    if ( (Close[0] < Open[0])
    && (Close[1] < Open[1])
    && (Close[2] > Open[2])
    && (Close[3] > Open[3])
    )

    {
    BullishBCD2 = true;
    Divp1 = Low[1];
    BarsCounter1 = CurrentBar;
    }

    if((Close[0] < Close[1])
    && (BullishBCD2 == true)
    && (Close[0] > Open[0])
    && (Close[1] > Open[1])
    )

    {
    Draw.Line(this, test+CurrentBar, false, CurrentBar - BarsCounter1, Low[0], BarsCounter1, Divp1, Brushes.White, DashStyleHelper.Solid, 2, true);
    }​



    Click image for larger version

Name:	image.png
Views:	226
Size:	13.6 KB
ID:	1274041


    #2
    Hello cryfgg,

    Thanks for your post.

    If the script is not behaving as expected then it is necessary to add debugging prints to the script to understand exactly how your logic is behaving and drawing lines on the chart.

    Add prints to the script (outside the conditions) that prints out each of the values being used within the conditions. Also, add prints one line above the Draw.Line() method to see exactly what values you are passing into the Draw.Line() method.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    43 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    26 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X