No announcement yet.

Partner 728x90


Performance of indicator with flexible input

  • Filter
  • Time
  • Show
Clear All
new posts

    Performance of indicator with flexible input


    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,

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

    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:

    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.


      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.

      Last edited by Rollins; 11-04-2007, 11:37 PM.


        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.


        Latest Posts


        Topics Statistics Last Post
        Started by Paul Penton, Today, 10:42 PM
        0 responses
        1 view
        Last Post Paul Penton  
        Started by mo_fi, Today, 10:08 PM
        0 responses
        Last Post mo_fi
        by mo_fi
        Started by Oracletrades, Today, 10:02 PM
        0 responses
        1 view
        Last Post Oracletrades  
        Started by jeronymite, Today, 09:15 PM
        0 responses
        1 view
        Last Post jeronymite  
        Started by temtam, Today, 07:56 PM
        0 responses
        Last Post temtam
        by temtam