Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Error on Converting Max or Min Statements
Collapse
X
-
Thank you so much JessicaP. I was able to figure out the code.
Many thanks for your support.
-
Hello alligator,
Since we have determined NinjaTrader, NinjaScript, and C# are all working as designed and I was able to answer your questions about their functionality, we are reaching the limit of the scope of the service we may provide. There are some logical steps that seem to be missing, such as accounting for the period of time between 6:30 and 7:01 in the morning when your 7:01 bars are not available, and instances where bars are created before 6:30 in the morning, which I do not see any logic in your code to account for.
I am a technical support expert. If you would like I can speak with one of my colleagues who is an expert on the community surrounding NinjaTrader, who can help put you in contact with a professional NinjaScript consultant.
Leave a comment:
-
Originally posted by NinjaTrader_JessicaP View PostThank you for this additional information alligator. I am glad we were able to determine why this is occurring. It looks like MAX and MIN are operating as specified, and are warning you that they are being passed in a zero value.
As to why they are being passed in a zero value, it looks like the lines in the most recent code sample we will need to review are lines 95 through 97.
It turns out that startBarsAgo and endBarsAgo can indeed be zero values. The documentation for GetBarIdxByTime, here,
provides no guarantees against non-zero values. It is in fact expected that these can be zero, since zero is a valid BarsAgo index. It is very likely that the reason you are getting zero values, is because there are points during historical data processing where you are attempting to pass in DateTime objects for which there are no corresponding bars.
You will therefore need to refactor your code. Since your code appears to be an attempt to retrieve values from 06:30 AM and 07:01 AM, I would like to recommend instead using the GetBar method documented here,
We are happy to help in any other way we can.
I followed your recommendation and used the GetBar method instead. I still get the same errors in trace file and output window when I apply it to a 5 minutes chart.
Thanks a bunch and have a wonderful time.Attached Files
Leave a comment:
-
Thank you for this additional information alligator. I am glad we were able to determine why this is occurring. It looks like MAX and MIN are operating as specified, and are warning you that they are being passed in a zero value.
As to why they are being passed in a zero value, it looks like the lines in the most recent code sample we will need to review are lines 95 through 97.
It turns out that startBarsAgo and endBarsAgo can indeed be zero values. The documentation for GetBarIdxByTime, here,
provides no guarantees against non-zero values. It is in fact expected that these can be zero, since zero is a valid BarsAgo index. It is very likely that the reason you are getting zero values, is because there are points during historical data processing where you are attempting to pass in DateTime objects for which there are no corresponding bars.
You will therefore need to refactor your code. Since your code appears to be an attempt to retrieve values from 06:30 AM and 07:01 AM, I would like to recommend instead using the GetBar method documented here,
We are happy to help in any other way we can.
Leave a comment:
-
Originally posted by NinjaTrader_JessicaP View PostThank you again, alligator.
It looks like your MAX and MIN arguments are getting invalid values as their second argument. I am attaching a copy of your code with some trace information added, which will help us debug what is occurring. Could you send us the final output matching my additions to your code that occur either in your logs or your output window, after intentionally running your indicator again and forcing it to crash?
I run your modified version and here is what I get from trace file:
" Indicator 'OpenRange': Error on calling 'OnBarUpdate' method on bar 1: Object reference not set to an instance of an object. "
And here is what I get from output file:
"startBarsAgo: 0
endBarsAgo: 0
Value of property 'Period' of NinjaScript 'MAX' is 0 and not in valid range between 1 and 2147483647.
Indicator 'OpenRange': Error on calling 'OnBarUpdate' method on bar 1: Object reference not set to an instance of an object. "
I can't see how the startBarsAgo and endBarsAgo have 0 value since both of these are clearly defined as non-zero parameters.
Thank you again.Attached FilesLast edited by aligator; 10-30-2016, 10:21 PM.
Leave a comment:
-
Thank you again, alligator.
It looks like your MAX and MIN arguments are getting invalid values as their second argument. I am attaching a copy of your code with some trace information added, which will help us debug what is occurring. Could you send us the final output matching my additions to your code that occur either in your logs or your output window, after intentionally running your indicator again and forcing it to crash?Attached Files
Leave a comment:
-
Originally posted by NinjaTrader_JessicaP View PostHello alligator, and thank you for your question.
I have prepared a simplified, stripped down indicator which does not produce the message in question. It operates over the same time period as the MAX indicator you produced on line 137, and on the same data series. I would like to advise either refactoring your code to use a call similar to the call in the attached indicator, or adding your code to the attached indicator piece-by-piece until it works as desired. If any questions come up in your refactor process, please let us know and we will be happy to assist further.
I followed your example and refactored the code as instructed. It does compile but as you can see I am still getting the same Error as noted above when applied to the chart and nothing happens.
Than you.Attached Files
Leave a comment:
-
Hello alligator, and thank you for your question.
I have prepared a simplified, stripped down indicator which does not produce the message in question. It operates over the same time period as the MAX indicator you produced on line 137, and on the same data series. I would like to advise either refactoring your code to use a call similar to the call in the attached indicator, or adding your code to the attached indicator piece-by-piece until it works as desired. If any questions come up in your refactor process, please let us know and we will be happy to assist further.Attached Files
Leave a comment:
-
Error on Converting Max or Min Statements
Dear Support,
There are many NT7 indicators that include a MAX or MIN statement. When converting these indicators to NT8 using the conversion tool on this forum the conversion will compile nicely. However, for some indicators, when the indicator is applied to a chart this error pops up and nothing happens.
" Value of property "Period" of NinjaScript"MAX" is 0 and not in valid range between 1 and 2147483647."
The attached converted Open Range Indicator is a simple example. There are already conditions to assure the value for "period" is not 0. The syntax for lines 137 and 140 is per documentation. Also, looking at trace and log file only the above error is repeated.
Could you please perhaps comment or see what causes this error?
Many Thanks.Attached FilesTags: None
- Likes 1
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
3 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Leave a comment: