Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Problem with LowestBar()
Collapse
X
-
Problem with LowestBar()
I have a scenario where LowestBar() is returning the current bar as the lowest even though the bar previous to the current bar is actually the lowest. I'm using Yahoo historical daily feed for the S&P500. The 1st bar close is $870.26. The 2nd bar close is $871.79. The statement: if (LowestBar(Close, LookBackPeriod) == 0) where LookBackPeriod=1 is processing out as "true" for some reason. I monitored variable values in Debug via Visual Studio 2008 Pro.
Tags: None
-
aascotty, in the future could you please just ask a question once? Thank you.
As for your inquiry, the code is working correctly. The code you posted asks this: if the lowest price bar occurs in the latest one bar, evaluate true. Since there is only one bar being looked at (LookBackPeriod = 1), it will always be true. If you'd like to monitor more bars in the past, you can change the look back period to a higher value. For example, to get the lowest bar of the last 10 bars: LowestBar(Close, 10).AustinNinjaTrader Customer Service
-
Problem with LowestBar()
I tried it with a lookback period of 2 and the if statement is still evaluating to "true". According to the NinjaTrader documentation, the lookbackperiod includes the bars before the current bar. If the current bar is the 2nd bar of the data feed, a lookback period of 1 should include the 1st bar of the data feed. Like I said, assuming your advice was correct, I tried a lookback period of 2 bars and the if statement still evaluated to true.
Comment
-
Problem with LowestBar()
"Working with price data" in Help documentation verifies what I'm saying with an example. The following is the copy and paste:
You will notice that to reference any price data you need to include a value for [int barsAgo]. This is a very simple concept; barsAgo represents the number of bars ago to reference and int indicates that barsAgo is an integer value. As an example, we could write a statement to check if the the high price of 1 bar ago is less than the high price of the current bar like this:
High[1] < High[0];
Comment
-
aascotty, please take a look at the attached screenshot and indicator. Keep in mind we're using the close prices to determine the lowest "low". I chose the line on close chart type because it is easiest to see how LowestBar() works.
I'm not saying the documentation is incorrect, but sometimes it is best to test an idea out yourself to see how it works.AustinNinjaTrader Customer Service
Comment
-
Originally posted by aascotty View Post"Working with price data" in Help documentation verifies what I'm saying with an example. The following is the copy and paste:
You will notice that to reference any price data you need to include a value for [int barsAgo]. This is a very simple concept; barsAgo represents the number of bars ago to reference and int indicates that barsAgo is an integer value. As an example, we could write a statement to check if the the high price of 1 bar ago is less than the high price of the current bar like this:
High[1] < High[0];AustinNinjaTrader Customer Service
Comment
-
LowestBar() problem not resolved
I included the Close prices for bar 1 and 2 in my original post: 1st bar close is $870.26. The 2nd bar close is $871.79. Why isn't the statement: if (LowestBar(Close, LookBackPeriod) == 0) where LookBackPeriod=2 evaluating to false if what you are saying is correct? The attachment you responded with does not clear anything up for me. Please forward my problem to technical support. It looks like there is a bug or inconsistency in Ninjatrader. At the very least, have tech support provide me with a correct explanation for how LowestBar() is really supposed to work.
Comment
-
Originally posted by aascotty View PostI included the Close prices for bar 1 and 2 in my original post: 1st bar close is $870.26. The 2nd bar close is $871.79. Why isn't the statement: if (LowestBar(Close, LookBackPeriod) == 0) where LookBackPeriod=2 evaluating to false if what you are saying is correct? The attachment you responded with does not clear anything up for me. Please forward my problem to technical support. It looks like there is a bug or inconsistency in Ninjatrader. At the very least, have tech support provide me with a correct explanation for how LowestBar() is really supposed to work.
I will propose another scenario: the most recent bar's (bar 0) close is 4. The second most recent bar's (bar 1) close is 5. Bar 2's close is 6.
Code:LowestBar(Close, 1) // will return 0, indicating the current bar has the lowest close (which makes sense because it is the only bar being looked at) LowestBar(Close, 2) // will return 1, indicating that one bar ago was the lowest close LowestBar(Close, 3) // will return 2, indicating that two bars ago (3rd most recent bar) was the lowest close.
AustinNinjaTrader Customer Service
Comment
-
LowestBar() problem unresolved
Per the Ninjatrader documentation, I'm assuming the convention or "bars ago" of accessing price data with LowestBar() is the same as accessing a DataSeries object such as Close[0] or Close[1]. Close[0] implies current bar or zero bars ago. Close[1] implies 1 bar ago. LowestBar(Close,0) means current bar and no lookback period. LowestBar(Close,1) means a lookback period that includes the current bar and the bar before it or 2 bars total. Otherwise, the documentation on the LowestBar() function is at best ambiguous.
Nothing changes in my scenario if I use a lookback period of 1 or 2. LowestBar() is not seeing that the current bar Close of $871.79 is not lower than the 1 bar ago Close prior to the currentbar of $870.26. The statement "if (LowestBar(Close, LookBackPeriod) == 0)" with a lookback of 2 bars should be evaluating to "false".
Please forward my problem to tech support.
Comment
-
Incorrect. lookBackPeriod is not the same concept as [] index values.
0 lookback period means zero bars to test. You still get a value from it to prevent errors, but it is not meaningful. 1 means test 1 bar or the current bar. lookback of 1 is not useful either since you are only testing the current bar and there is no need to do such a test. 2 means test current bar and previous bar.Josh P.NinjaTrader Customer Service
Comment
-
Problem with LowestBar() unresolved still
Nothing changes in my scenario if I use a lookback period of 2. LowestBar() is not seeing that the 1 bar ago Close, prior to the currentbar, of $870.26 is the lowest bar when compared to the current bar Close of $871.79. The statement "if (LowestBar(Close, LookBackPeriod) == 0)" with a lookback of 2 bars should be evaluating to "false". It's evaluating to "true". Debug is showing LowestBar(Close, LookBackPeriod) is evaluating to zero which causes the entire "if" statement to evaluate to "true".
Please forward my problem to tech support.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
14 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
229 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
||
Started by agclub, 04-21-2024, 08:57 PM
|
3 responses
17 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:42 PM
|
||
Started by TradingLoss, 04-21-2024, 04:32 PM
|
4 responses
43 views
2 likes
|
Last Post
by TradingLoss
Yesterday, 11:40 PM
|
||
Started by cre8able, 04-17-2024, 04:16 PM
|
6 responses
56 views
0 likes
|
Last Post
by cre8able
Yesterday, 09:20 PM
|
Comment