• 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

Using Input series within a multi-series Strategies

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

    Using Input series within a multi-series Strategies

    I have created an Indicator that takes the Indicator's UI Parameter Input series. I want to call these Indicator from within a strategy that has two series. How can I set the Input series for the main series and secondary one (same instrument, higher timeframe)? To address the primary series, when I go Strategy's UI properties I see an Input series property, but it cannot be changed as the found in the Indicator.

    Thanks

    #2
    Hello GARZONJ,

    Thanks for your post.

    You would need to assign the higher time frame series to the indicator in State.DataLoaded().

    Here is an example of the code generated by the strategy builder where it uses an EMA(14) of the chart series and an EMA(14) of a higher time frame. Note that in the code "Closes[1]" points to the close values of the added data series (15 minute bars). For further understanding, please review: https://ninjatrader.com/support/help...nstruments.htm and https://ninjatrader.com/support/help...us/?closes.htm

    Code:
      public class twotimefraemexample : Strategy
        {
            private EMA EMA1;
            private EMA EMA2;
    
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Strategy here.";
                    Name                                        = "twotimefraemexample";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 1;
                    EntryHandling                                = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy                = true;
                    ExitOnSessionCloseSeconds                    = 30;
                    IsFillLimitOnTouch                            = false;
                    MaximumBarsLookBack                            = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution                            = OrderFillResolution.Standard;
                    Slippage                                    = 0;
                    StartBehavior                                = StartBehavior.WaitUntilFlat;
                    TimeInForce                                    = TimeInForce.Gtc;
                    TraceOrders                                    = false;
                    RealtimeErrorHandling                        = RealtimeErrorHandling.StopCancelClose;
                    StopTargetHandling                            = StopTargetHandling.PerEntryExecution;
                    BarsRequiredToTrade                            = 20;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration    = true;
                }
                else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Minute, 15);
                }
                else if (State == State.DataLoaded)
                {                
                    EMA1                = EMA(Close, 14);
                    EMA2                = EMA(Closes[1], 14);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (BarsInProgress != 0)
                    return;
    
                if (CurrentBars[0] < 1)
                    return;
    
                 // Set 1
                if ((CrossAbove(Close, EMA1, 1))
                     && (Close[0] > EMA2[0]))
                {
                }
    
            }
    Last edited by NinjaTrader_PaulH; 07-11-2019, 06:20 AM. Reason: Changed user name
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul,

      I am trying to use Input series. If I understand the documentation correctly, when using the Input series (instead of the Close), you are giving the user the option of selecting the Input series from within the Indicator's configuration window. For every indicator, a user can set the Input series to Close (default one), Open Median, etc. Base on this parameter, the indicator's logic will use the selected serie.

      Now, if I am calling this Indicator from within a Multi-Series strategy, how will a user be able to set the Input series? The reason why a developer would use the Input series is to provide the flexibility to the user to select the serie they want the indicator to use. I can definitely hard-code it in the manner you have shown me. But I want to know if there is a way to give this flexibility to user from within a Strategy in the same manner that there is the flexibility for an indicator.

      Comment


        #4
        Hello GARZONJ,

        Thanks for your reply and clarification.

        You can present the user with a "PriceType" selector and then in state.DataLoaded, hardcode the options based on the user input.

        Example of price type selector:

        [NinjaScriptProperty]
        [Display(Name=" Higher Time frame PriceType", Description="Select price Type (Close, high, Low, etc.)", Order=2, GroupName="HTF pricetype")]
        public PriceType fastPriceType
        { get; set; }


        Example in State.dataLoaded of applying the price type

        if (fastPriceType == PriceType.Close)
        EMA2 = EMA(Closes[1], Period).Value;
        if (fastPriceType == PriceType.High)
        EMA2 = EMA(Highs[1], Period).Value;
        if (fastPriceType == PriceType.Low)
        EMA2 = EMA(Lows[1], Period).Value;
        if (fastPriceType == PriceType.Median)
        EMA2 = EMA(Medians[1], Period).Value;
        if (fastPriceType == PriceType.Open)
        EMA2 = EMA(Opens[1], Period).Value;
        if (fastPriceType == PriceType.Typical)
        EMA2 = EMA(Typicals[1], Period).Value;
        if (fastPriceType == PriceType.Weighted)
        EMA2 = EMA(Weighteds[1], Period).Value;
        Last edited by NinjaTrader_PaulH; 07-11-2019, 06:19 AM. Reason: Changed user name
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul,

          Since there is no way to control the Input series for the higher timeframe series, I can see that your code is the way to go.

          What about the primary series within the Strategy? When working with Indicators, the user can select the Input within the Indicator's configuration window using the Input Series parameter. Although I see a similar parameter in the Strategy's configuration window, I don't see the option of modifying the primary series's Input series. If there is no place for the user to set Input series within the Strategy's configuration window, then I would have to do a similar solution for the primary series. Could you please confirm that there is no place to set the Input series for the primary series within a Strategy.

          Thanks.

          Comment


            #6
            Hello GARZONJ,

            Thanks for your reply.

            Glad to see you changed your user name, I'll edit my previous posts to remove the e-mail name.

            To confirm, a strategy will adopt the charts bars and does not provide a means to select price type in the parameters.



            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by escobar63, Yesterday, 05:06 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by Brutus, Today, 06:00 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by phesi, Today, 03:36 AM
            2 responses
            7 views
            0 likes
            Last Post phesi
            by phesi
             
            Started by Guru73, Today, 01:35 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by Maxwell123, Today, 12:34 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_ChrisSch  
            Working...
            X