NinjaTrader custom indicator problem with multiple data series - freezing - futures io
futures io futures trading



NinjaTrader custom indicator problem with multiple data series - freezing


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one TraderOfFortune with 7 posts (1 thanks)
    2. looks_two Fat Tails with 6 posts (0 thanks)
    3. looks_3 vegasfoster with 2 posts (0 thanks)
    4. looks_4 Zondor with 1 posts (0 thanks)
    1. trending_up 9,323 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 17 posts
    2. attach_file 5 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • 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 and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

NinjaTrader custom indicator problem with multiple data series - freezing

(login for full post details)
  #1 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

Hi everybody,

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:
 
Code
 Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Plot0"));
			
			Add("MSFT", PeriodType.Second, 1, MarketDataType.Last);
			Add("ADBE", PeriodType.Second, 1, MarketDataType.Last);
			Add("GOOG", PeriodType.Second, 1, MarketDataType.Last);
			Add("IBM", PeriodType.Second, 1, MarketDataType.Last);
			
            Overlay				= false;

and this is the OnBarUpdate() code:


 
Code
			if 	(CurrentBars.Length < 5)
				return;

			double average = 0, val1 = 0, val2 = 0, val3 = 0, val4 = 0;

			var count = Math.Min(Math.Min(CurrentBars[1],CurrentBars[2]), 
								 Math.Min(CurrentBars[3], CurrentBars[4]));	
			if (count > 0)
			{
				val1+= BarsArray[1][0];
				val2+= BarsArray[2][0];
				val3+= BarsArray[3][0];
				val4+= BarsArray[4][0];
				average = (val1 + val2 + val3+ val4)/4;

				Log("Avg(" + val1 + "+" + val2 + "+" + val3+ "+"+ val4 + ")=" + average,  NinjaTrader.Cbi.LogLevel.Information);
			
				Plot0.Set(average);
			}
			else
			{
				Log("Avg(???)=undef",  NinjaTrader.Cbi.LogLevel.Information);
			
				Plot0.Set(0);
			}
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.

Reply With Quote

Can you help answer these questions
from other members on futures io?
What blockvolume is visible? - order processing
NinjaTrader
Volume Profile Indicator for Ninja Script in NT8
NinjaTrader
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
Improve current ZigZag indicator in NT8
NinjaTrader
Neurological explanations for trading Success
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
137 thanks
Want your NinjaTrader indicator created, free?
32 thanks
Big Mike in Ecuador
30 thanks
Saturday Morning Market Replay!
20 thanks
Selling Options on Futures?
19 thanks
 
(login for full post details)
  #3 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received


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.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

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.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
Portland Oregon, United States
 
Experience: Beginner
Platform: NinjatraderŽ
Broker: CQG, Kinetick
Trading: Gameplay KlownbineŽ Trading of Globex
 
Zondor's Avatar
 
Posts: 1,347 since Jul 2009
Thanks: 1,245 given, 2,721 received

You need to use the BarsInProgress criterion to set the values of the different dataseries.

if(BarsInProgress==1) value of first ADDed data series = Closes [1][0]
if(BarsInProgress==2) value of second ADDed data series = Closes [2][0]

 
Code
      
      if(BarsInProgress==1) val1+= BarsArray[1][0];
      if(BarsInProgress==2) val2+= BarsArray[2][0];
      if(BarsInProgress==3) val3+= BarsArray[3][0];
      if(BarsInProgress==4) val4+= BarsArray[4][0];
You should be using try{ }catch blocks with diagnostic Print statements to show you what is going wrong during development.

You can get the value of each added data series only when the value of BarsInProgress is the one associated with that data series.

There are some examples on the Ninjatrader forum. Search it for "BarsInProgress".

etc

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received

@ 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.

@ TraderOfFortune:

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.

Chart and indicator attached.

Are you working for MultiCharts?

Attached Thumbnails
Click image for larger version

Name:	ES 03-12 (Second)  14_12_2011.jpg
Views:	138
Size:	67.9 KB
ID:	57318  
Attached Files
Register to download File Type: zip TestMTF4.zip (1.9 KB, 68 views)
Reply With Quote
 
(login for full post details)
  #7 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

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.

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


TraderOfFortune View Post
@ 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.

I do not think that it is linked to MaximumBarsLookBack.

You did not publish the entire code of your indicator, so I cannot tell you where the difference lies.

Reply With Quote
 
(login for full post details)
  #9 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received


Fat Tails View Post
I do not think that it is linked to MaximumBarsLookBack.

You did not publish the entire code of your indicator, so I cannot tell you where the difference lies.

Well, it's pretty much the indicator itself, the rest of the code is auto-generated.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received



TraderOfFortune View Post
Well, it's pretty much the indicator itself, the rest of the code is auto-generated.

Why don't you publish your indicator, so that somebody else can test it?

Reply With Quote
 
(login for full post details)
  #11 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

Yes, indeed - why?
Voila - attached.

@Fat Tails: Btw, do you run 64-bit version or 32? Mine is 32-bit NT running on XP.

Attached Files
Register to download File Type: cs ACustomInd.cs (6.8 KB, 31 views)
Reply With Quote
 
(login for full post details)
  #12 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


TraderOfFortune View Post
Yes, indeed - why?
Voila - attached.

@ Fat Tails: Btw, do you run 64-bit version or 32? Mine is 32-bit NT running on XP.


Your indicator works here as expected, and there is no freeze. I use XP 32-bit.

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

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!

Reply With Quote
The following user says Thank You to TraderOfFortune for this post:
 
(login for full post details)
  #14 (permalink)
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 839 received

Oh yes, lather up and clean your logs you dirty, dirty...oh wait, wrong forum, sorry nm.

Reply With Quote
 
(login for full post details)
  #15 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


TraderOfFortune View Post
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 greed 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!

This a direct consequence of the Heisenberg Uncertainty Principle.

Reply With Quote
 
(login for full post details)
  #16 (permalink)
Rostov-on-Don, Russia
 
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received


Fat Tails View Post
This a direct consequence of the Heisenberg Uncertainty Principle.

Damn, I knew I shouldn't have missed my quantum physics classes!

Reply With Quote
 
(login for full post details)
  #17 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,790 since Jun 2009
Thanks: 32,314 given, 97,610 received


Fat Tails View Post
Heisenberg Uncertainty Principle


TraderOfFortune View Post
Damn, I knew I shouldn't have missed my quantum physics classes!

That's ok, the only thing I think of when I hear Heisenberg is Breaking Bad.






Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #18 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,731 received


Big Mike View Post
That's ok, the only thing I think of when I hear Heisenberg is Breaking Bad.
Mike

That is one of the reasons that the days of US leadership in the world can be counted.

Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > NinjaTrader custom indicator problem with multiple data series - freezing


Last Updated on December 22, 2011


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts