NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-17-2008, 10:30 AM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default bar length question

Hi,

I'm simply trying to calculate the "length" of a Candlestick bar (in "pips") using:

BODY = (Math.Abs(Open[0] - Close[0])) * TickSize;

This however is producing odd results (in Output Window)...what is the error in syntax here? I would think something like this is hardcoded into NT ("BarLength" for example) however I don't see it in the documentation...
Burga1 is offline  
Reply With Quote
Old 04-17-2008, 10:50 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

how about

Math.Abs(High[0] - Low[0])

this will give you the difference in Pips if sub pip is disabled otherwise 1/10ths of pips.
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-17-2008, 11:17 AM   #3
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for the reply, still having problems, here is the line I'm using:

BODY = Math.Abs(Open[0] - Close[0]);

You can see from screenshots (2 periods, 12:30pm and 12:45pm) that what is being returned is not what should be expected (in pips)...I'm looking for the absolute value of the pips (thus .00039999 should be "4" pips)...I have no explanation for the information at 12:45pm.

Also can you explain "sub pip disabling", I'm not familiar with it...
Attached Images
File Type: jpg screen1.JPG (27.4 KB, 8 views)
File Type: jpg screen2.JPG (27.7 KB, 6 views)
Burga1 is offline  
Reply With Quote
Old 04-17-2008, 11:54 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

then divide by TickSize and round to an integer value. Sub pip support is should be enabled (Tools > Options > Misc) when using data from MBT or IB for FX.
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-17-2008, 12:15 PM   #5
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you. I've enabled that sub pip and divided by TickSize. That seems to improve things. Can somebody supply an explanation why the pips seem to be multiples of 10? For example 4 pips is displaying as 40, 6 pips as 60, 22 pips as 220...etc...?
Burga1 is offline  
Reply With Quote
Old 04-17-2008, 12:22 PM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Since you are using sub-pips which prices are quoted in 1/10ths of pips, thus, divide by 10 you will get the pip value.
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-17-2008, 12:26 PM   #7
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for your help.
Burga1 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


All times are GMT -6. The time now is 04:50 PM.