![]() |
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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: May 2008
Posts: 221
Thanks: 12
Thanked 2 times in 2 posts
|
Here is an indicator I created to use as a volatility reference;
Up.Set(Close[0]+ATR(1)[0]); I use it on a 2 minute chart and it priduces outputs that are even with the tick, ie, 1025.00, 1025.25, 1025.50, etc. I have another indicator which does not produce an output which is even with the tick, ie, 1025.888, 1025.092, etc. For this indicator, I enclosed the formula in Math.Round, which fixed the problem. To be consistent, I also used the Math.Round() in the above indicator incase it ever produced an uneven number that might be ignored by my strategy when placing stops. The indicator now looks like this; Up.Set(Math.Round(Close[0]+ATR(MyInput0)[0])); This changed the output, as if it was rounding twice. I realize I can just remove the Math.Round(), but I am trying to understand what is happening, as I'm creating a strategy to use this indicator for setting stops and don't want it to be ignored by the strategy if uneven numbers ever exist. Can anyone please explain this or offer some advice? Thank you. Safetrading |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Not sure what you mean exactly, but to round to ticksize you should use this: http://www.ninjatrader-support.com/H...2TickSize.html
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: May 2008
Location: Hartford, CT. USA
Posts: 618
Thanks: 12
Thanked 24 times in 18 posts
|
safetrading,
It could be your formula. try breaking the formula down to just what you want. Original Up.Set(Math.Round(Close[0]+ATR(MyInput0)[0])); --------------------------------------------------------- round just Close[0] Up.Set((Math.Round(Close[0])+ATR(MyInput0)[0])); -------------------------------------------------------- round just ATR... Up.Set((Close[0])+ Math.Round(ATR(MyInput0)[0])); ------------------------------------------------------------ round both seperately. Up.Set((Math.Round(Close[0])+ Math.Round(ATR(MyInput0)[0]))); -------------------------------------------------------------- RJay |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: May 2008
Posts: 221
Thanks: 12
Thanked 2 times in 2 posts
|
Thanks, I'll give it a try. I appreciate your time.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ToTime(Time[0]) Confusion | shiptastic | Automated Trading | 14 | 11-20-2010 08:40 PM |
| Order by Account Size triggers confusion | tooearly | Automated Trading | 2 | 06-22-2009 08:12 AM |
| historical backtesting data confusion | diffused | Miscellaneous Support | 9 | 11-17-2008 05:55 AM |
| barsInProgress bug or confusion | woodside | General Programming | 6 | 02-06-2008 09:47 PM |
| Confusion on Event Driven OnBarUpdate Mechanism for Multiple Instrument Strategy | shliang | Strategy Development | 6 | 01-29-2008 05:04 AM |