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:	235
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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    245 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    157 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    165 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    250 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    201 views
    0 likes
    Last Post CarlTrading  
    Working...
    X