Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Data box shows different value than strategy
Collapse
X
-
Data box shows different value than strategy
I have RSI and EMA of RSI (with RSI as input series). On the databox it shows the correct values for the EMA and RSI, however when I add the code to the strategy and get values, the EMA shows a different value. Thanks!!Tags: None
-
It is not just rounding. The values are very different. On the chart, I add RSI of 12 smoothing 3, and then add EMA 43 with the Input series of RSI (12,3).
In the strategy my code is code -
RSI1 = RSI(Close, Convert.ToInt32(12), 3);
EMA1 = EMA(RSI1, 43);
On the chart (Data box) the values
RSI - 63.44
EMA of RSI - 53.69
and on the Strategy debug mode the
RSI - 56.9177110180709---
EMA of RSI - 49.7395368011012
Comment
-
Hello Graci117,
Thanks for your post.
When you mention "and on the Strategy debug mode" are you referring to adding Prints to your script that print out the values to a New > NinjaScript Output window?
I have created a simple indicator that plots the RSI and EMA values you shared and prints them to a NinjaScript Output window. When comparing the values from the test script to the RSI and EMA indicators that come default with NinjaTrader using the same exact properties as the code, I am seeing values that match in the chart, Data Box, and NinjaScript Output window.
See the attached screenshot.
Also, see the attached script used to test this.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Originally posted by NinjaTrader_BrandonH View PostHello Graci117,
Thanks for your notes.
You could find the test script attached in post # 4. Attached you'll find the images for the RSI and EMA indicator parameters I used for comparison.
I have also attached the script to this post.
Comment
-
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Originally posted by NinjaTrader_BrandonH View PostHello Graci117,
Thanks for your note.
It seems the Forums hid the scripts from view. I have made them visible again so that you could view them.
Attached to this post I have also added a screenshot of the test indicator's code.
Indicator 'RSIMA': Error on calling 'OnBarUpdate' method on bar 10: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
And on the strategy code I get this error =
Strategy 'FILevelsOMARSI/-1': An order placed at '06/01/2023 09:41:00' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.
Comment
-
Originally posted by Graci117 View Post
Unfortunately, the script is still not available. I tried to create the indicator and for some reason when I try to add the indicator I get this error on the output window -
Indicator 'RSIMA': Error on calling 'OnBarUpdate' method on bar 10: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
And on the strategy code I get this error =
Strategy 'FILevelsOMARSI/-1': An order placed at '06/01/2023 09:41:00' has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met.
Comment
-
Hello Graci117.
Thanks for your note.
Please see the test script attached on post # 6 as seen in the attached screenshot.
The error message "You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart." means that you are trying to access an invalid index. A more simple example using one series would be on bar 5 you check for 6 BarsAgo. There are not yet 6 bars so the CurrentBar minus 6 would be a negative number or a non-existent bar.
A CurrentBar check could be used in your indicator's logic to ensure that a certain number of bars have processed before the indicator begins calculation. A CurrentBar check would look something like this.
Code:if (CurrentBar < 10) return;
See the help guide documentation below for more information.
CurrentBar - https://ninjatrader.com/support/help...currentbar.htm
CurrentBars - https://ninjatrader.com/support/help...urrentbars.htm
Make sure you have enough bars - https://ninjatrader.com/support/help...nough_bars.htm
The second "error" is simply a warning message letting you know that the strategy tried to place a trade before the BarsRequiredToTrade property was met. The BarsRequiredToTrade property is set to 20 by default and means that there must be at least 20 bars on the chart before a trade is placed.
You could consider setting this property to 0 in the Properties section of the Strategies window when enabling your strategy.
See this help guide about the BarsRequiredToTrade property: https://ninjatrader.com/support/help...totrade<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wisdomspoon, Today, 03:50 PM
|
3 responses
14 views
0 likes
|
Last Post
![]()
by rockmanx00
Today, 04:33 PM
|
||
Started by Mountain_cast, 02-10-2025, 11:14 PM
|
2 responses
19 views
0 likes
|
Last Post
![]() |
||
Started by Robotman, Today, 01:06 PM
|
2 responses
37 views
0 likes
|
Last Post
![]()
by Robotman
Today, 02:05 PM
|
||
Started by PH_GMT, Today, 12:40 PM
|
4 responses
19 views
0 likes
|
Last Post
![]()
by PH_GMT
Today, 02:41 PM
|
||
Started by 80grit, 01-11-2025, 10:57 AM
|
13 responses
285 views
0 likes
|
Last Post
![]()
by Skifree
Today, 02:23 PM
|
Comment