Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Error on calculating min/max value - please check GetMinMaxValue method
Error on calculating indicator min/max value for indicator 'RSI'. Please check the 'GetMinMaxValues' method: Index was outside the bounds of the array.
Attached is the indicator.
By default there is no 'symbol1' .. 'symbol10' (blank string). The error only occurs when using RSI and selecting this indicator as the input series. If you plot the indicator by itself (no RSI) it works fine.
The error also only occurs when symbol1 (or greater) are populated. So to reproduce, set symbol1 to something (ie SPY, ES 09-12, AAPL, etc). It will plot by itself fine, but when used inside RSI it generates the above error.
I couldn't find a resolution so far or even what is causing the problem.
Help appreciated. Don't laugh at code, I'm 3-years out of practice writing C#.
@Big Mike: I have checked it on my side. I am getting the same error: Empty panel, array out of range error for GetMinMaxValues.
I am rather sure that it is one of the NinjaTrader mystery bugs. The code of the indicator has nothing to do with it, as it has no custom plot and does not use the offending method.
What you can do is the following:
(1) Apply the indicator -> nothing will appear
(2) Change the hoizontal compression by clicking below the x-Axis and slightly compress the chart
(3) Press F5 -> now the indicator should be shown
(4) Send a note to NinjaTrader support for explaining the peculiar behavior
I contacted NT support, and it seems that Add() does not support dynamic calls.
What I don't understand is why it works as a stand-alone indicator, with the code as-is, which includes a dynamic Add() [in other words, the instrument is a variable and not fixed in the code].... but yet doesn't work when wrapping RSI around it.
Or perhaps it isn't working correctly now, and I've just not realized that the plot is completely wrong?
I have tested this again. I have indeed coded a few indicators which call bartype and period dynamically (see VisualSMA and VisualEMA). Maybe I have committed a crime.... But as the name says, those were not really meant to be called by strategies.
To test the issue I have converted the indicator Synthetic to one which does not allow to define the instruments dynamically. The indicator (attached) is well-behaved and also calculates correct values. I have left a few Print instructions allowing to check the values for the added instruments.
Now, the original Synthetic file is also working well, if you put it on your chart. If you apply an indicator to it, it will first show an empty panel, but if you refresh via F5, it will display correct results.
I cannot entirely explain the behaviour, but it is probably linked to the Initialize section(). I suspect that
-> the code in the Initialize and Properties section is already executed when you open the indicator dialogue box of the chart panel, otherwise you would not see the information in the dialogue box
-> the Initialize() section is executed again, when the indicator is added to the chart, thus taking into account the new parameters
-> the Initialize() section is not executed again, when an indicator is called by another indicator, which means that parameter changes will not be applied to the Add instructions
What I do not know, is why pressing F5 leads to a parameter update.
I can confirm this behavior as I was working on an other indicator today which had a print statement in Initialize(). As always@Fat Tails is spot on. I am still waiting for the day where i can prove him wrong...
So Harry, do you see any problem with me calling it via a strategy? I believe that in a backtest, each run causes a Init(). As for running the strategy live on a chart, I guess I may need to hit F5?
I would definitely not start working on a backtest with an indicator that might create problems. Better start with a simple configuration. Why don't you settle for one synthetic instrument - type Synthetic2 - , which means that you can avoid adding instruments dynamically.
When the simple approach works as expected, you can then start to add complexity to your backtest by doing all sorts of things for which NinjaTrader has not been designed. I do not think you will convince the genetic optimizer to run a backtest by optimizing the instruments added.