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 rexsole, Today, 08:39 AM
    0 responses
    4 views
    0 likes
    Last Post rexsole
    by rexsole
     
    Started by trilliantrader, Yesterday, 03:01 PM
    3 responses
    30 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    4 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Brevo, Today, 01:45 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rjbtrade1, 11-30-2023, 04:38 PM
    2 responses
    74 views
    0 likes
    Last Post DavidHP
    by DavidHP
     
    Working...
    X