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

Alert within a box

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

    Alert within a box

    Hi

    I want to develop a simple indicator with two pieces of conditions

    1. Price close with in 10% of high. I know how to write code for this condition
    2. Price stays with in the rectangle I draw on the chart

    I dont know how to write code for the second condition. I want to draw a rectangle box every morning (which means it will be different/new one every morning but it will be rectangle) and check price stay with in the box I draw . I want draw same rectangle box in other instruments as well.

    Can you please help me the code?

    #2
    Hello chakriare,

    Thank you for your post.

    Below is an example of looping through the drawing objects to find a manually draw rectangle and check if the close is within the bounds of the rectangle.
    Code:
    		protected override void OnBarUpdate()
    		{
    			foreach (DrawingTool draw in DrawObjects)
    			{
    				if (draw is DrawingTools.Rectangle && draw.IsUserDrawn)
    				{               
    					Rectangle uRect = draw as DrawingTools.Rectangle;
    					if ((Close[0] > uRect.StartAnchor.Price || Close[0] > uRect.EndAnchor.Price) && (Close[0] < uRect.StartAnchor.Price || Close[0] < uRect.EndAnchor.Price))
    					{
    						Print("Current price is within the rectangle.");
    					}
    				}
    			}
    		}
    For information on DrawObjects please visit the following link: http://ninjatrader.com/support/helpG...rawobjects.htm

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mattbsea, Today, 05:44 PM
    0 responses
    4 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    31 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,282 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    20 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Working...
    X