Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Drawing Objects in conditions

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

    Using Drawing Objects in conditions

    I'm setting up (trying) gap strategy using prior OHLC indicator. I've set a condition where the if the open is above/below the prior days close it draws a ray. Now I wish to make a condition if the price crosses above/below that ray to trigger an action. Is this possible? I've read a couple forum post about drawing objects, but I haven't found anything on setting the object as a condition after it's been created.

    #2
    Hello Zinger357,

    Thanks for your post.

    You could loop through the DrawObjects collection to detect if there is a Ray drawing object on the chart and use StartAnchor.Price and EndAnchor.Price to get the prices of the StartAnchor and EndAnchor of that Ray drawing object.

    The StartAnchor.Price or EndAnchor.Price could then be used for conditions in your strategy to detect if the current Close price (Close) is greater than the StartAnchor.Price or EndAnchor.Price.

    I have attached an example script you could view that demonstrates this concept. The indicator draws a Ray on the chart from the Low price 10 bars ago to the High price of the current bar. Then, the indicator loops through the drawing objects on the chart and prints out the StartAnchor.Price and EndAnchor.Price of the Ray drawing object in a New > NinjaScript Output window.

    See the help guide documentation below for more information.

    Draw.Ray(): https://ninjatrader.com/support/help...8/draw_ray.htm
    DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
    ​IDrawingTool ChartAnchors: https://ninjatrader.com/support/help...rawingtool.htm

    ​Please let me know if I may assist further.
    Attached Files
    Last edited by NinjaTrader_BrandonH; 12-08-2022, 08:57 AM.
    <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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    596 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X