Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with the Draw.Line & Draw.Rectangle commands

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

    Need help with the Draw.Line & Draw.Rectangle commands

    Hi All,

    I have put together some thing that highlights the first 3 hours of Asia, London and New York sessions. So in between those designated times a rectangle is drawn using the highest price and lowest price.

    As someone completely new to this I looked at the open range indicator provided by Ninja trader as a template and then used draw. Rectangle to shade the area to visually stand out. So after working out various problems regarding the tag name and getting this to work I am stumped by something I cant make sense of.

    This problem seems to be with both the draw. Line and rectangle command. The main function itself works but for each session I have an extra rectangle above and below the main area that's highlighted with the price and for the New York session, there is an overlap. How can I get rid of the extras?

    Anyone able to point me in the right direction?

    Thanks in advance
    Doug
    Attached Files

    #2
    Hello Luckychip,

    Thanks for your post.

    To understand exactly how your logic is behaving, such as drawing objects that are unexpected on the chart, you would need to add debugging prints to the indicator script that prints out the values being used for your Draw methods.

    One line above the Draw method where you are drawing that rectangle on the chart, add prints that print out the startY and endY values being passed in for the rectangle, the Time[0], the Tag name, and the CurrentBar to see how your logic is evaluating.

    Once you understand how those rectangles are being drawn, you could modify your script accordingly to suit your overall goal.

    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


      #3
      Hi Brandon,

      Thanks for your reply. I will take a look, and hopefully see what's wrong.

      Regards
      Doug

      Comment


        #4
        Hi Brandon,

        Just an update, the problem had nothing to do with the commands but with the starting and closing time parameters.
        The following code was missing for the times.

        dtStartTime = new DateTime (dt.Year, dt.Month, dt.Day, dtStartTime.Hour, dtStartTime.Minute, dtStartTime.Second);
        dtEndTime = new DateTime (dt.Year, dt.Month, dt.Day, dtEndTime.Hour, dtEndTime.Minute, dtEndTime.Second);

        As soon as that was changed the extra rectangles disappeared, so thank you for the help

        Regards
        Doug ​
        Last edited by Luckychip; 11-08-2023, 09:26 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        636 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        568 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X