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)
Looking for NT7 CCI Indicator based on EMA and not SMA
The CCI Indicator on NT is SMA based, since I use EMA on my charts I would like to know if there is anyone out there that has coded one with EMA in mind and not SMA.
Thank you much for your time and help.
Can you help answer these questions from other members on NexusFi?
If the goal was to code an indicator that would waste as many CPU cycles as possible by calculating the same things over and over again, this was a brilliant success.
I will edit this post shortly to update a revised version.
OK, 20 minutes later, the wiseguy is back as promised, and here it is. It's obvious from the code that the loop that was previously executed on every tick is now executed only once per bar, and that the value of the EMA, previously calculated (period +1) times on every TICK, is now only calculated once per tick. (You can't rely on Ninjatrader's unreliable built in caching mechanism to ensure that these repetitive calculations do not happen.)
Of course, I also am using a predefined reusable instance of the EMA class to avoid having to create a new instance thereof on every bar, or to rely on the hope that Ninjatrader's creaky caching mechanism would render that expensive repetitive instantiation operation unnecessary.
However, benchmark testing is not included in my fee so the only thing to go on right now is the above analysis.
I also added multi colored plotting. To compensate for the reduced cpu load, I greatly lengthened the description of the indicator, written in classic Ninjatrader Gibberish style.
Default for COBC is now false. I am confident that performance will still be more than adequate.
I could also use the IDataseries trick to allow the calculation to be done with an MA selected from lots of different types of MA's in an Enum. Which other MA's would we like to see?
Saturday afternoon update. In the cold light of day I realized that I had over optimized. The expression within the loop depends on the current value of the EMA, which can change intrabar. Therefore the loop needs to run and the indicator needs to be updated not just OnFirstTickOfBar, but whenever the value of the EMA changes. But that is a lot less often than on every tick so there is still a huge reduction in CPU use compared to the original code. Code updated at 435PM PT October 20.
and no, the goal was not to code an indicator that would waste as many CPU cycles as possible. that's exactly why I specifically wrote: this is the standard cci indicator from nt
@Zondor, would you consider taking a look at Winfrey's adaptive cci with the same critical eye. You are quite the wise guy...but I think I'm starting to understand your tone better.
I think that Mike's has a lot of code that I am not using. Just wonder if this version is a hog like you described or if cleaning out the unused code would make any difference.
Congratulations ... you are now part of the elite group who have been Zondor'd ... that means you have unselfishly given of your time and written enough free indicators to catch the attention of he who stands watch over us mortal coders from on high ... and guides us down the path of the straight and narrow ...
Disclaimer: This post does not represent the view point of the owners, managers, or moderators of this web site and is not intended as a slam against any moderator, board member, any banned former members whose name we dare not say, any other living person, any recently living person or any person or persons whose status we are not sure of and especially not for any platform vendor with a questionable product and a pit bull lawyer. This post is meant purely for entertainment and should not be confused with a real thought.
I am not a programmer, coach, trainer or self appointed guru and do NOT hold myself up to be a good example for anything. I do not have a book, trading room or seminar. Even though I have an opinion on every subject under the sun, I do not give financial advice. Nor should I be held responsible for feeble attempts at humor at your expense. This post is meant purely for entertainment and should not be confused with a real thought.
I'm just a simple man trading a simple plan.
My daddy always said, "Every day above ground is a good day!"
If some of you guys would think about the changes I make and start using those techniques in your code, my sarcastic tone would miraculously change to one of sweetness. There is a thread regarding optimization of C# code that hasn't been very active lately, but I consider it to be very important. Unless you never use any indicators.
Is anyone interested in transposing my code into C# for use with NT7? I have the code as well as the article that it was based on. If anyone wants to tell me how to display the charts in the …
Mwinfrey, post 20: “The Adaptive_CCI and Alternate_Adaptive_CCI indicators are ones that a friend and I developed a very long time ago. I updated them a bit and got them running on NT7. Posted them at the link below. Let me know what you think about them.
The Adaptive_CCI was developed by Mike Winfrey and Gumphrie what seems like a very long time ago for NT 6.0.
As of 9/16/2011, this version runs on NT 7 and was cleaned up a bit. Still unused code out there but left it for posterity reasons.
There …
If the goal was to code an indicator that would waste as many CPU cycles as possible by calculating the same things over and over again, this was a brilliant success.
I will edit this post shortly to update a revised version.
OK, 20 minutes later, …
above and update to latest cs file attached to that post.
The Adaptive CCI had a huge amount of arithmetic on every tick that only needs to be done once per bar. This is typical of the amateurish way that Ehlers indicators have been coded for Ninjatrader.
I really hit the jackpot by moving a switch in OnBarUpdate where it was running on every tick, to OnStartUp(), where it only runs ONCE. That's ONE TIME ONLY, not once per bar.
With the reduction of unnecessary arithmetic, this should run OK on the new default of COBC false. The number of executions of OnBarUpdate could be further reduced around 70% by not responding to redundant intrabar ticks. I will leave that to someone else to implement. It takes three lines of code.
I made some changes, but did not test it at all. At this point all I know is that it compiles. You guys are welcome to check it. Look for multiple /// marks where the changes were made.
Updated the file at 616PM PT. Added instantiation of the array of intrabar invariant Doubles to Initialize block. Updated display name for period of EMA used for slope calculation. Changed default plot colors.