NinjaTrader custom indicator problem with multiple data series - freezing - NinjaTrader Programming | futures io social day trading
futures io futures trading


NinjaTrader custom indicator problem with multiple data series - freezing
Updated: Views / Replies:5,617 / 17
Created: by TraderOfFortune Attachments:5

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 5  
 
Thread Tools Search this Thread
 

NinjaTrader custom indicator problem with multiple data series - freezing

  #1 (permalink)
Trading Apprentice
Rostov-on-Don, Russia
 
Futures Experience: Beginner
Platform: NinjaTrader, TradeStation, MultiCharts, SierraChart, TWS, TradeStation
Favorite Futures: ES, MSFT
 
Posts: 7 since Dec 2011
Thanks: 0 given, 1 received

NinjaTrader custom indicator problem with multiple data series - freezing

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
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
las vegas
 
Futures Experience: Intermediate
Platform: Sierra Chart
Broker/Data: Velocity/IB
Favorite Futures: 6E
 
Posts: 1,147 since Feb 2010
Thanks: 304 given, 836 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
 
  #4 (permalink)
Trading Apprentice
Rostov-on-Don, Russia
 
Futures Experience: Beginner
Platform: NinjaTrader, TradeStation, MultiCharts, SierraChart, TWS, TradeStation
Favorite Futures: ES, MSFT
 
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
 
  #5 (permalink)
Elite Member
Portland Oregon, United States
 
Futures Experience: Beginner
Platform: Ninjatrader®
Broker/Data: CQG, Kinetick
Favorite Futures: Gameplay Klownbine® Trading of Globex
 
Zondor's Avatar
 
Posts: 1,327 since Jul 2009
Thanks: 1,246 given, 2,635 received

missing the Bippy

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


Last edited by Zondor; December 14th, 2011 at 01:03 PM.
Reply With Quote
 
  #6 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary

@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
NinjaTrader custom indicator problem with multiple data series - freezing-es-03-12-second-14_12_2011.jpg  
Attached Files
Register to download File Type: zip TestMTF4.zip (1.9 KB, 62 views)
Reply With Quote
 
  #7 (permalink)
Trading Apprentice
Rostov-on-Don, Russia
 
Futures Experience: Beginner
Platform: NinjaTrader, TradeStation, MultiCharts, SierraChart, TWS, TradeStation
Favorite Futures: ES, MSFT
 
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
 
  #8 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


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
 
  #9 (permalink)
Trading Apprentice
Rostov-on-Don, Russia
 
Futures Experience: Beginner
Platform: NinjaTrader, TradeStation, MultiCharts, SierraChart, TWS, TradeStation
Favorite Futures: ES, MSFT
 
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
 
  #10 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary



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

Reply



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

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
NinjaTrader + Interactive Brokers (IB) + Kinetick. Multiple Data Feeds BCNTrader NinjaTrader 8 November 9th, 2012 09:46 PM
Multiple data indicator larssan EasyLanguage Programming 2 October 8th, 2011 07:54 PM
Is a custom program required for this ? (Ratio instruments and Multiple data sources) Overview NinjaTrader Programming 7 September 16th, 2011 11:39 AM
2nd Data Series Problem nismo EasyLanguage Programming 7 September 8th, 2011 10:30 AM
Multiple data series code help rkepler EasyLanguage Programming 3 August 16th, 2011 10:12 AM


All times are GMT -4. The time now is 09:11 AM.

Copyright © 2017 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
Page generated 2017-12-16 in 0.15 seconds with 20 queries on phoenix via your IP 54.83.122.227