Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Performance of indicator with flexible input

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Performance of indicator with flexible input

    Hi,

    I made my indicators a lot more flexible by writing a base indicator that I feed all the data and which knows by passing an int parameter which MA to apply.
    I got the idea when I looked at how Gumphrie used enums and with some trying I was able to come up with a nice use for them.

    Now what I' really love to know is, how much does this degrade performance/memory use being a deoptimzation. Possible ways to keep this in check.

    To get a bit of a performance increase I thought I'd try something else.
    You can see it in the MAV 1.1, it never throws and exception an never calls OnBarUpdate, so I get nada nothing zilch.

    04.11.2007 15:32:25|3|4|Failed to call method 'Initialize' for indicator 'MAxOver': Unable to cast object of type 'NinjaTrader.Indicator.DataSeriesHelper' to type 'NinjaTrader.Data.Bars'.
    04.11.2007 15:33:23|3|4|Error on calling the 'OnBarUpdate' method for indicator 'IndicatorX' on bar 0: Unable to cast object of type 'NinjaTrader.Data.DataSeries' to type 'NinjaTrader.Data.Bars'.
    Ok fixed that in the MAV 1.2 ... but dunno if it will improve performance that much.
    Actually the MAV 1.2 version is much worse, chart was stuck for a second after dragging.


    Thanks in advance and cheers,

    Rollins
    Attached Files
    Last edited by Rollins; 11-04-2007, 10:54 AM.

    #2
    That's a clever technique.

    But why not move the initialization of "indicator" to the Initialize() method?

    That's probably what's making it slow... it doesn't have to be done for every bar.

    By the way, there's a full list of these moving averages in this post: http://www.ninjatrader-support.com/v...ht=Stochastics

    I also based the selection of moving average types in StochasticsWithSmoothing on Gumphrie's enumeration example, and I've now updated it to use the Indicator class, like is in your code. I don't know why but somehow or other that refinement escaped me when I originally wrote this code, but I like this much better.

    You might want to steal the enum and CalcMovingAverage() method from that file, it might save you a little work. And it is well commented.

    Comment


      #3
      Thanks for the suggestion and the code KBJ.

      The performance in the MAV 1.2 version with the indicator class is worse then the original one.

      Just setting the indicator on Initialize() was my first optimization idea, but it doesn't work, as seen in MAV_v1.1 and the quote I posted.

      Of course it might work with the right adjustments, but I don't know what they should be.

      What I am wondering about is how wasteful such an indicator really is, but that's something for the NT guys because it requires knowledge of how it's handled internally.

      MAV_1.0 works fine, if anyone wants to use it.

      Cheers
      Last edited by Rollins; 11-05-2007, 12:37 AM.

      Comment


        #4
        You're welcome, Rollins. Grab the enum and CalcMovingAverage() method out of the StochasticsWithSmoothing.cs file and I think you'll find it will help.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        388 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        29 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        22 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        7 views
        0 likes
        Last Post funk10101  
        Working...
        X