NexusFi: Find Your Edge


Home Menu

 





Ninja Trader BUG Open[0] and Close[0]


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Warren B. with 7 posts (1 thanks)
    2. looks_two max-td with 5 posts (0 thanks)
    3. looks_3 roonius with 2 posts (4 thanks)
    4. looks_4 Big Mike with 2 posts (0 thanks)
    1. trending_up 6,677 views
    2. thumb_up 6 thanks given
    3. group 2 followers
    1. forum 17 posts
    2. attach_file 5 attachments




 
Search this Thread

Ninja Trader BUG Open[0] and Close[0]

  #11 (permalink)
 Warren B. 
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.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Can I use Ehlers Periodogram as the lookback for another …
NinjaTrader
static margin on the right side of a chart
NinjaTrader
Footprint for strategy Builder
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
16 thanks
GFIs1 1 DAX trade per day journal
13 thanks
The Trading Pit "Futures VIP" Account Journal
12 thanks
TopStepX from TST
10 thanks
Trading with Intuition
10 thanks
  #12 (permalink)
 Warren B. 
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!!!


Started this thread Reply With Quote
Thanked by:
  #13 (permalink)
 
max-td's Avatar
 max-td 
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 ?

max-td
Reply With Quote
  #14 (permalink)
 bukkan 
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.

Reply With Quote
Thanked by:
  #15 (permalink)
 
max-td's Avatar
 max-td 
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;

??

max-td
Reply With Quote
  #16 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295


max-td View Post
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

Reply With Quote
Thanked by:
  #17 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


roonius View Post
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 ?

max-td
Reply With Quote
  #18 (permalink)
 
roonius's Avatar
 roonius   is a Vendor
 
Posts: 131 since Jun 2009
Thanks Given: 20
Thanks Received: 295


max-td View Post
so this is also a working solution simular to your own sugestion, roonius ?

Yes - it is another working solution.

Reply With Quote
Thanked by:




Last Updated on December 16, 2009


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts