Anyone have any hints for optimizing C# code? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Anyone have any hints for optimizing C# code?
Updated: Views / Replies:24,872 / 111
Created: by ZTR Attachments:14

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
 14  
 
Thread Tools Search this Thread
 

Anyone have any hints for optimizing C# code?

  #61 (permalink)
Trading for Fun
Dallas TX/USA
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: AMP/CQG
Favorite Futures: ES
 
Posts: 154 since Jun 2009
Thanks: 33 given, 281 received


MXASJ View Post
Is there an example of how this code could be optimized? I'm still not getting what types of calculations should be taken out of OnBarUpdate... or am I totally missing something? Thanks for the enlightenment.

There's no way to meaningfully speed up that indicator. It basically does the minimum that it needs to do. Make sure the market analyzer only uses the minimum number of bars back that you need. And if you only need the realtime numbers, you could try adding:

 
Code
if(!Historical) { ... }
... around the whole thing, to avoid doing any calculation at all, except for the most recent bar. (you'd do this in a copy of ROC, and not ROC itself!)

Since ROC does so little, I don't know how much that would help, but it's the first thing I'd try.

Reply With Quote
The following user says Thank You to Richard for this post:
 
  #62 (permalink)
 Vendor: www.integrity-traders.com 
East Rochester, NY
 
Futures Experience: Intermediate
Platform: NT
 
eDanny's Avatar
 
Posts: 327 since Jul 2009
Thanks: 17 given, 419 received

Richard, what is the difference here?

private EMA emathingy;
emathingy = EMA(CCI(CCIPeriod),10);

and

private Indicator emathingy;
emathingy = EMA(CCI(CCIPeriod),10);

Which is better here?

private MACD macdThingamajig;
macdThingamajig = MACD(12,26,9);

then use: macdThingamajig.Avg[0]

or

DataSeries macdThingamajig;
macdThingamajig = MACD(12,26,9).Avg;

then use: macdThingamajig[0]


Last edited by eDanny; May 28th, 2010 at 06:05 PM.
Reply With Quote
 
  #63 (permalink)
Trading for Fun
Dallas TX/USA
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: AMP/CQG
Favorite Futures: ES
 
Posts: 154 since Jun 2009
Thanks: 33 given, 281 received



eDanny View Post
Richard, what is the difference here?

private EMA emathingy;
emathingy = EMA(CCI(CCIPeriod),10);

and

private Indicator emathingy;
emathingy = EMA(CCI(CCIPeriod),10);

It's the same thing, except in the second example you can hold a reference to any indicator, versus just the EMA. The main difference you'll see in practice is when indicators define properties for their plots. So, for instance, MACD has the "Avg" property, which gets you access to the dataseries for that particular plot. If you have "Indicator macd", then the best you can do is look up macd.Values[1]... because "Indicator" does not have a property named "Avg."

Performance-wise, it's a wash, though. It's the same objects. Just a matter of what you need access to through the variables you use.



eDanny View Post
private MACD macdThingamajig;
macdThingamajig = MACD(12,26,9);

then use: macdThingamajig.Avg[0]

or

DataSeries macdThingamajig;
macdThingamajig = MACD(12,26,9).Avg;

then use: macdThingamajig[0]

Again, it's all the same objects doing the same computations... the only difference is what you can access through the variables you are holding. In this case, you are storing off a reference to a particular dataseries in the MACD. So, from that point forward, you have direct access to it, but not to the MACD. You didn't store off a reference to the MACD.

But, if all you were needing was the 'Avg' data, then it's all the same, and in fact a few cycles faster. Nothing you'd notice, so I tend to store references to the indicators for maximum flexibility.

Reply With Quote
The following user says Thank You to Richard for this post:
 
  #64 (permalink)
 Vendor: www.integrity-traders.com 
East Rochester, NY
 
Futures Experience: Intermediate
Platform: NT
 
eDanny's Avatar
 
Posts: 327 since Jul 2009
Thanks: 17 given, 419 received

Thanks Richard, those answers are exactly what I was thinking but wanted confirmation.

Dan

Reply With Quote
 
  #65 (permalink)
Elite Member
Toronto, Canada
 
Futures Experience: Beginner
Platform: Ninja Trader
Broker/Data: Amp Futures/ Zen-Fire
Favorite Futures: Still not sure what is my favourite instrument.
 
SteveM's Avatar
 
Posts: 155 since Jul 2009
Thanks: 464 given, 109 received

I am unable to download the indicator Double Stochastic Optimized, LATEST VERSION V1.4 on NT6.5. I am getting a message: Import failed. Ninja Trader could not decompress the Ninja Script Archive File: Version required to extract this entry not supported (45).

Can some one help me with this. Please.

Thanks

Steve

Thanks
Steve
Be like a JAGUAR. Crouching, perfectly still, waiting for the set up to come to you, then pouncing without hesitation or thought. You only need one to feed the family
Reply With Quote
 
  #66 (permalink)
 R.I.P. 1960-2010 
 
Futures Experience: Advanced
Platform: NinjaTrader7
Broker/Data: Mirus RCG/Zen-Fire
Favorite Futures: CL & 6e, looking at ES, ZB and AU again.
 
ZTR's Avatar
 
Posts: 2,099 since Nov 2009
Thanks: 1,104 given, 1,390 received


SteveM View Post
I am unable to download the indicator Double Stochastic Optimized, LATEST VERSION V1.4 on NT6.5. I am getting a message: Import failed. Ninja Trader could not decompress the Ninja Script Archive File: Version required to extract this entry not supported (45).

Can some one help me with this. Please.

Thanks

Steve

Try deleting the info.xml file from the installation folder and paste in the .cs file into an empty shell. I have posted about this if you have questions.

But you may have to upgrade to NT7 to get the really good stuff on the forum, Zondor and I no longer even have 6.5 on our computers.

R.I.P. Andy Zektzer (ZTR), 1960-2010.
Please visit this thread for more information.
Reply With Quote
 
  #67 (permalink)
Elite Member
Nederland
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Zen-Fire
 
Posts: 19 since Jun 2009
Thanks: 41 given, 4 received

Double Stochastic Optimized, LATEST VERSION V1.4

Can someone please make this indicator working for NT 6.5
Thanks

Reply With Quote
 
  #68 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,354 given, 83,237 received


kees View Post
Can someone please make this indicator working for NT 6.5
Thanks

I think you are in the wrong place. You should post requests for indicators in this thread:

https://futures.io/elite-group-trading-methods/1261-want-your-indicator-created-free.html

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #69 (permalink)
 R.I.P. 1960-2010 
 
Futures Experience: Advanced
Platform: NinjaTrader7
Broker/Data: Mirus RCG/Zen-Fire
Favorite Futures: CL & 6e, looking at ES, ZB and AU again.
 
ZTR's Avatar
 
Posts: 2,099 since Nov 2009
Thanks: 1,104 given, 1,390 received

Great ideas to optimize NT indy's From Richad Todd: http://www.movethemarkets.com/downloads/rwt/rwt004/

I truely believe this person runderstands computer processing, especially when applied to NinjaTrader 7 & hope this is not considered an advertisement for this site as I have no idea if he is selling anything directly on this page.

R.I.P. Andy Zektzer (ZTR), 1960-2010.
Please visit this thread for more information.
Reply With Quote
 
  #70 (permalink)
Elite Member
San Francisco Bay Area
 
Futures Experience: Intermediate
Platform: NT,TOS,IB
Favorite Futures: ES,CL,TF
 
Posts: 278 since Jun 2010
Thanks: 154 given, 267 received


I originally wrote code for solving NP-type problems and performance was the one benchmark we were measured on. When I originally started writing my trading system, I was surprised to see that most commercial libraries do not use data-persistence and loop through the entire data-series. To me that was like driving forward while looking backwards.

It took me some time to realize that most of the world, including most programmers, are not measured on performance and are focussed on getting the job done quickly instead of performance. However when you start running this kind of code on tick data, you very quickly will start maxing out.

This brings me to the question of NT. Though NT7 uses multi-threading the main charting loop is still a single thread. This means that your super-duper quad-core CPU will basically be no better than a single/dual core CPU with the same core and memory system (assuming you are not doing anything else). Back-testing and optimization does use the multiple threads and will run faster on more cores.

I have often faced performance problems with NT with the CPU maxing out at 25% (One core of a quad core). I now try to use CalculateOnBarClose or write my own sampled version for larger time-frame bars i.e. the indicator will update 10 times, during the bar but not on every tick. However this is still inefficient since the OnBarUpdate() method is called on every tick and the check for sampling does take some time.

I am attaching the basic sampled indicator from which other indicators can derive from. It is very much like the gomi indicators. There is also an example which converts the TSI to the SampledTSI.

Attached Files
Register to download File Type: cs AviatSampledIndicator.cs (7.9 KB, 43 views)
Register to download File Type: cs BlauTSISampled.cs (11.4 KB, 40 views)
Reply With Quote

Reply



futures io > > > > > Anyone have any hints for optimizing C# code?

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
Hints, Tips & Gocthas NW27 MultiCharts 2 August 7th, 2011 04:11 PM
Can someone code this ? skyfly NinjaTrader Programming 8 April 25th, 2011 01:40 PM
Japan's Intervention Hints Fail to Stall Yen's Strength Quick Summary News and Current Events 0 September 8th, 2010 03:20 AM
Optimizing Range Bar Settings? daedalus Traders Hideout 3 February 1st, 2010 01:00 AM
Does anyone esle find Ninja problematic for optimizing strategies? rsi77 NinjaTrader 3 June 17th, 2009 09:32 PM


All times are GMT -4. The time now is 03:05 PM.

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.20 seconds with 40 queries on phoenix via your IP 54.163.209.109