Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing a Period.Type into the Indicator for Additional Instrument

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

    Passing a Period.Type into the Indicator for Additional Instrument

    I know I can pass through a symbol for an additional instrument into an indicator by:

    declaring a string input variable
    eg. private string symbol = @"SPY"

    and then adding the new instrument in Initialize
    eg. Add(symbol, Period.Type.Day, 1)

    And that way I can manually change what additional instrument I add into the indicator every time I set my parameters for an indicator.

    But how do I change the Period.Type? It's not a string, so I can't just enter in another string parameter/variable.

    #2
    im sure there is a more convenient way but what u can do is to use(depending on how many periodtypes u acutally wanna have) either a bool or a list.

    if for example ur only interested in alternating between day and minute bars u could just use a bool that u would set in the parameters to true (for minute) and false for day. and then use a simple if(bool) then add period.minute and if(bool==false) add period.day statment or something like that. the actual value for the periodtype can then be inserted by a simple int parameter.

    for a list dropdown u would use something like this

    public enum PeriodTypes
    {
    Day,
    Minute,
    Range
    }
    and this for you parameters
    [NinjaTrader.Gui.Design.DisplayName("Periodypes"), GridCategory("Parameters")]
    public PeriodTypes PeriodTypes
    {
    get
    {
    return this.periodtypes;
    }
    set
    {
    this.periodtypes = value;
    }
    }
    and then again use simple if statements.

    if(PeriodTypes== PeriodTypes.Day)
    Add()
    make sure to use
    using System.Collections.Generic;
    declaration (first region) when using a list.
    Last edited by BigRo; 11-17-2015, 06:25 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pilotfo, Today, 12:50 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DTSSTS, Today, 11:35 AM
    2 responses
    11 views
    0 likes
    Last Post DTSSTS
    by DTSSTS
     
    Started by sinpeople, Today, 07:20 AM
    2 responses
    9 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Frank1000, Today, 03:05 AM
    5 responses
    16 views
    0 likes
    Last Post Frank1000  
    Started by fscabrera03, Yesterday, 01:18 PM
    2 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X