Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    191 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,230 views
    0 likes
    Last Post xiinteractive  
    Started by andrewtrades, Today, 04:57 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X