![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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... |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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...?
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you for your help.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|