NinjaTrader Support Forum  
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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

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

Reply
 
Thread Tools Display Modes
Old 08-28-2009, 02:07 PM   #1
safetrading
Senior Member
 
Join Date: May 2008
Posts: 221
Thanks: 12
Thanked 2 times in 2 posts
Default Rounding confusion

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

safetrading is offline  
Reply With Quote
Old 08-28-2009, 02:11 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Not sure what you mean exactly, but to round to ticksize you should use this: http://www.ninjatrader-support.com/H...2TickSize.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-28-2009, 02:46 PM   #3
RJay
Senior Member
 
Join Date: May 2008
Location: Hartford, CT. USA
Posts: 618
Thanks: 12
Thanked 24 times in 18 posts
Default

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
RJay is offline  
Reply With Quote
Old 08-28-2009, 02:49 PM   #4
safetrading
Senior Member
 
Join Date: May 2008
Posts: 221
Thanks: 12
Thanked 2 times in 2 posts
Default Thanks

Thanks, I'll give it a try. I appreciate your time.
safetrading is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 01:49 PM.