Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Ninja Trader BUG Open[0] and Close[0]
Updated December 16, 2009
Top Posters
looks_one
Warren B.
with 7 posts (1 thanks)
looks_two
max-td
with 5 posts (0 thanks)
looks_3
roonius
with 2 posts (4 thanks)
looks_4
Big Mike
with 2 posts (0 thanks)
trending_up
6,615 views
thumb_up
6 thanks given
group
2 followers
forum
17 posts
attach_file
5 attachments
Ninja Trader BUG Open[0] and Close[0]
December 16th, 2009, 01:08 PM
BERLIN - Germany
Experience: Advanced
Platform: Sierra, Esignal, (NT)
Trading: FDAX, 6E , Stocks/ETFs
Posts: 48 since Nov 2009
Thanks Given: 45
Thanks Received: 46
Ok. I post it there.
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
December 16th, 2009, 02:21 PM
BERLIN - Germany
Experience: Advanced
Platform: Sierra, Esignal, (NT)
Trading: FDAX, 6E , Stocks/ETFs
Posts: 48 since Nov 2009
Thanks Given: 45
Thanks Received: 46
Hey,
it was just a programming issue !!!
Here is the right code if someone has the same problem:
if ( Math.Abs(Close[ 0 ] - Open[ 0 ]) < TickSize * 0.5 )
BarColor = Color.Yellow;
Thanks goes to roonius!!!
December 16th, 2009, 02:45 PM
Frankfurt
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927
here the solution - posted by roonius :
It is double.Epsilon issue.
You can try replacing your condition like this:
if ( Math.Abs(Close[ 0 ] - Open[ 0 ]) < TickSize * 0.5 )
BarColor = Color.Yellow;
double.Epsilon is C# thing when dealing with double values - you have to be careful when comparing them.
https://bytes.com:443/topic/c-sharp/answers/253204-meaning-double-epsilon
__________________
www.TradingStudies.com
ThanX,
very interesting !
anymore easy to understand expalainations for this ?
December 16th, 2009, 02:59 PM
Calcutta, India
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271
while programming for an vb.net app i had a hell of a time before realizing this. then treated the price variable as Decimals.
December 16th, 2009, 03:06 PM
Frankfurt
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927
do i have the same problems if i do it like this :
double open = Open[ 0 ]
double close= Close[ 0 ]
if ( close == open )
BarColor = Color.Yellow;
??
December 16th, 2009, 03:58 PM
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295
max-td
do i have the same problems if i do it like this :
double open = Open[ 0 ]
double close= Close[ 0 ]
if ( close == open )
BarColor = Color.Yellow;
??
You will have the same problem, if you do like this.
NinjaTrader has an undocumented method (so they are aware of this of course)
if(Instrument.MasterInstrument.Compare(Open[0], Close[0]) == 0)
BarColor = Color.Yellow;
public int Compare ( double price1 , double price2 )
Member of NinjaTrader.Cbi . MasterInstrument
Summary:
Compares 2 prices with respect to the NinjaTrader.Cbi.MasterInstrument.TickSize to ensure accuracy when dealing with floating point precision.
Parameters:
price1 :
price2 :
Returns:
1: If price1 is greater than price2, -1: If price1 is less than price2, 0: If price1 is equal to price2
December 16th, 2009, 04:12 PM
Frankfurt
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927
roonius
NinjaTrader has an undocumented method (so they are aware of this of course)
if(Instrument.MasterInstrument.Compare(Open[0], Close[0]) == 0)
BarColor = Color.Yellow;
so this is also a working solution simular to your own sugestion, roonius ?
December 16th, 2009, 05:12 PM
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295
max-td
so this is also a working solution simular to your own sugestion, roonius ?
Yes - it is another working solution.
Last Updated on December 16, 2009