Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Move Draw.Rectangle to X position (center of the Bar)

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

    Move Draw.Rectangle to X position (center of the Bar)

    Hello, I am developing my tool and I use Draw.Rectangle. I would like to know if there is any way to move the start of the rectangle further to the right. In the image it appears outside the bar and I want the rectangle to start in the center of the bar (where the green line is). I was looking at the possibility of using RenderTarget.DrawRectangle, but I will have to change a lot of the logic in my code. Thanks.
    Click image for larger version

Name:	eggtgt.png
Views:	85
Size:	4.5 KB
ID:	1316621
    Last edited by icebergdelphi; 09-02-2024, 04:28 PM.

    #2
    Hello icebergdelphi,

    Thank you for your post.

    Draw.Rectangle() does draw from the center of the bar, in your screenshot you can see it is actually drawing from the center of the green bar.

    If you were expecting it to draw from the center of the red bar, it means your Draw.Rectangle() call needs to be adjusted so it the startBar is the red bar instead of 1 bar behind.

    To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

    https://support.ninjatrader.com/s/ar...nd-TraceOrders​​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    577 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X