X

## Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com

 Indicator Development Support for the development of custom indicators using NinjaScript.

 10-03-2011, 03:34 PM #2 NinjaTrader_RyanM NinjaTrader Customer Service     Join Date: Sep 2009 Location: Denver, CO Posts: 8,117 Thanks: 249 Thanked 418 times in 415 posts Hello Ben, I read "within" to mean the distance between them. One way may be to nest multiple Math.Max() to take the highest of 3 values, and Math.Min to take lowest of the 3. Subtract these and you have the biggest difference among the 3 values. double a = EMA(10)[0]; double b = EMA(20)[0]; double c = EMA(30)[0]; double maxDiff = Math.Max(Math.Max(a, b), c) - Math.Min(Math.Min(a, b), c); For the alerting, you can set a plot value as 1 when true, and 0 when false. Then can set alerts when the value of your indicator == 1. if (maxDiff <= TickSize * 3) Value.Set(1); else Value.Set(0); Ryan M NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 The following user says thank you to NinjaTrader_RyanM for this post:
 10-03-2011, 03:48 PM #3 stocktraderbmp Senior Member   Join Date: Jun 2011 Location: Ireland Posts: 184 Thanks: 32 Thanked 20 times in 19 posts Yep I have used "within" as in: at the close of the bar the value of each ema must be "within" 3 ticks of each other. So if the value of the 10 ema is 1.3232 then the value of the 20 and the 30 must be <= 1.3235 and >= 1.3229. This "condition must be met for at least 5 0f 10 bars to give you an alert. Hope this clarifies
 10-03-2011, 03:54 PM #4 stocktraderbmp Senior Member   Join Date: Jun 2011 Location: Ireland Posts: 184 Thanks: 32 Thanked 20 times in 19 posts Just working through your answer now but its nearly 11pm here. Will write script tomorrow. Sleeping on it always helps but I think that you have hit the nail on the head so to speak. Couldn't see the wood for the trees but as always the simple solution is the best, thanks again.
 10-03-2011, 03:59 PM #5 stocktraderbmp Senior Member   Join Date: Jun 2011 Location: Ireland Posts: 184 Thanks: 32 Thanked 20 times in 19 posts Yep, going to stay up for 1 more Guinness and work through this but I can't see any problems; brilliant, neat solution and I now feel a little dumb !!! Thanks again.
 10-03-2011, 04:03 PM #6 NinjaTrader_RyanM NinjaTrader Customer Service     Join Date: Sep 2009 Location: Denver, CO Posts: 8,117 Thanks: 249 Thanked 418 times in 415 posts You're welcome. I'm happy to hear that worked out for you. Ryan M NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 10-06-2011, 07:46 AM #7 eroscoe Junior Member   Join Date: Mar 2011 Location: United Kingdom Posts: 1 Thanks: 0 Thanked 0 times in 0 posts Hi Ryan, this is my first time on the forum and not to sure how it all works yet. I am trying to write an alert for when the MACD line closes up/down in relation to its previouse bar. Anyones help would be appreciated. Thanks.
 10-06-2011, 08:14 AM #8 NinjaTrader_RyanM NinjaTrader Customer Service     Join Date: Sep 2009 Location: Denver, CO Posts: 8,117 Thanks: 249 Thanked 418 times in 415 posts Hello eroscoe, Welcome to the NinjaTrader forums! If you're just getting started with programming, would recommend the strategy wizard is the best starting point. You can setup conditions like this in a point and click interface, and then view and edit code as needed. If you want to compare a value to it's previous value to test if it's higher or lower, this could be done with rising and falling. There is a sample here that can help show you how rising and falling is setup in the strategy wizard: http://www.ninjatrader.com/support/f...ad.php?t=19384 See here for the strategy wizard section of our help guide: http://www.ninjatrader.com/support/h...egy_wizard.htm Ryan M NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule