I'm trying to develop an indicator that would calculate over multiple data series.
The main issue I'm having here is that after some time the indicator freezes and not only the indicator, but the whole application. Seldom it recovers from the frozen state, but most of the time it doesn't.
I can't see what I'm doing wrong.
Here's the indicator's Initialize() code:
and this is the OnBarUpdate() code:
Nothing too fancy, few lines of simple code.
I did try on a different PCs, and it seems that CPU speed and available memory do not affect much. In fact, memory consumption is pretty negligible.
Only thing I see is that you are pulling second data. I would have the input the same as the time frame you are trading off of, so if you are trading using a 5-minute chart, then try using 5-minute data as the input. I believe this will lessen the load and not have any effect on what you are seeing. If that doesn't help or you are using a second chart to trade and need second input, then try loading fewer days.
Thanks for the post, vegasfoster.
All data series have the same time-frame with the series on the chart. As of loading fewer days, it helps for some time, but eventually the result is the same.
@Zondor: BIP is not required. I do not systematically use it for my MTF indicators as it introduces a lag. We can discuss this via private message, if you are interested.
I cannot see any real problems with your code. I have just produced a small MTF indicator, which is attached, and which runs well and without any problems on my side. It basically uses your code.
The only thing that I have added is a check for CurrentBars[0], which represents the primary bar series of the chart.
Maybe you are running into trouble because you have a slow internet connection. The indicator that I have attached is running well and without any problems here.
Zondor, Fat Tails - many thanks for your feedback!
@Zondor: Fat Tails is right, using BIP gave the same result. Plus, it changes the logic a bit.
I did use try-catch though, as you've suggested to catch possible exceptions (not that I expected any, just to be sure) - none.
@Fat Tails: looked at your indicator - yeap, pretty close. I'm puzzled why your code works all right and mine doesn't... May be it's because you've limited the MaximumBarsLookBack?
My connection is rather fast, never had related issues before.
I'm converting indicators from EasyLanguage/PowerLanguage to Ninja and the opposite.
All right, folks - seems the mystery is resolved (at least I hope so). A friend of mine who owns a NinjaTrader license contacted them in my behalf describing the problem. They didn't give a solution, but suggested that the problem is supposedly because of intensive logging. In fact, NinjaTrader documentation has a mentioning of this issue, as it turned out.
I'd hardly call once a sec logging too intensive, so I did some tests and found out that the system rapidly slows down when there are many logs in the Log window. I suppose, when the .NET grid used in the Log window has too many lines it doesn't perform well. So, it's not the frequency that matters, but the quantity.
The lesson I leaned for myself - clean your logs periodically, if you're using log messages and running the system for a prolonged period of time.
Thanks to everybody for helping me out!
The following user says Thank You to TraderOfFortune for this post: