• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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, 05:25 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by topisi9359, Today, 06:54 AM
    0 responses
    1 view
    0 likes
    Last Post topisi9359  
    Started by HiddenPhilosopher, Today, 06:45 AM
    0 responses
    2 views
    0 likes
    Last Post HiddenPhilosopher  
    Started by PG7940, Today, 04:26 AM
    0 responses
    7 views
    0 likes
    Last Post PG7940
    by PG7940
     
    Started by marcus2300, Today, 02:25 AM
    0 responses
    2 views
    0 likes
    Last Post marcus2300  
    Started by drpapp, 01-24-2019, 06:57 AM
    5 responses
    69 views
    0 likes
    Last Post pjsmith
    by pjsmith
     
    Working...
    X