programming forum

Discussion in 'App Development' started by rosy2, Aug 30, 2011.

  1. pwrtrdr

    pwrtrdr

    I have a prgram that is custom written in C# for Ninja by another programmer and I want to add a parameter or two on top of what I have how could you help ?

    Thanks
     
    #11     Sep 17, 2011
  2. I'm assuming you have the source code available?
    If so, it's pretty easy to add parameters.
    The easiest way to see what you need to add is by creating a brand new strategy/indicator with a single parameter of the type you need (int, string, etc) using the Ninjatrader wizard. Once you've got that, open the generated code.
    There are two sections you'll need to replicate in your own code:

    1) Add a private local variable (found in the region "Variables")

    2) Add a new public property to expose the parameter (found in the region "Properties") I've included an example below. In this case, the property "LowThreshold" references the private variable "lowThreshold"
    Note, you need the two statements above the "public..." line as well.
    Depending on what type the parameter is, you may need to modify the "set" portion of the property, but other than that, it's pretty straightforward.

    Example: to add an integer called LowThreshold:

    In the Variables region, add:

    private int lowThreshold=0;

    In the Properties region, add:

    [Description("Lower threshold value.")]
    [GridCategory("Parameters")]
    public int LowThreshold
    {
    get { return lowThreshold; }
    set { lowThreshold = Math.Max(1, value); }
    }
     
    #12     Sep 17, 2011
  3. dsss27

    dsss27

    How about an F# code snippet on how to do a WMA, similar to convolution in the time domain?
     
    #13     Sep 17, 2011
  4. pwrtrdr

    pwrtrdr

     
    #14     Sep 17, 2011