Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Different instrument strategy

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

    Different instrument strategy

    Is it possible to create a strategy for instance, that would take data from a indicator running on RTY and trigger the order of M2K

    I do have the strategy running on RTY and all is good so just need a small amount of guidance.

    Thank you in advance

    Richard

    #2
    Hello Richard,

    Thanks for your post.

    Yes, that can be done.

    You would need to add the RTY instrument to the strategy and any indicators you use in the strategy can be configured to use that as the input source for that indicator.

    When you add a data series to a script you are creating a multi-instrument script and some coding changes would be required to address. This is the best source of information on handling a multi-Instrument (or time frame) script: https://ninjatrader.com/support/help...nstruments.htm The documentation includes using addDataSeriess() to add the RTY.

    You can also review the strategy "Sample Multi Instrument" strategy in your NinjaTrader which demonstrates the concepts of adding another instrument and then using, in this case, the ADX indicator, on the added data series.

    If you are using the Strategy Builder, this can also be done.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello Richard,

      Thanks for your post.

      Yes, that can be done.

      You would need to add the RTY instrument to the strategy and any indicators you use in the strategy can be configured to use that as the input source for that indicator.

      When you add a data series to a script you are creating a multi-instrument script and some coding changes would be required to address. This is the best source of information on handling a multi-Instrument (or time frame) script: https://ninjatrader.com/support/help...nstruments.htm The documentation includes using addDataSeriess() to add the RTY.

      You can also review the strategy "Sample Multi Instrument" strategy in your NinjaTrader which demonstrates the concepts of adding another instrument and then using, in this case, the ADX indicator, on the added data series.

      If you are using the Strategy Builder, this can also be done.
      Thank you will give that a try

      Comment


        #4
        Thank you for your help and I got this doing exactly what it is supposed to do.

        ! more question if I may can the indicator running on RTY be added to the M2K chart

        I tried


        else if (State == State.Configure)
        {


        // Add an RTY 208 ticks Bars object to the strategy
        AddDataSeries(RefInstName, BarsPeriodType.Tick, 208);
        }

        else if (State == State.DataLoaded)
        {
        hMA3indi = HMA3indi(BarsArray[1]());

        AddChartIndicator(hMA3indi);

        HMA1 = HMA3indi(BarsArray[1]);

        }


        but I get an error "method name expected"

        if i remove the () after BarsArray[1] hMA3indi = HMA3indi(BarsArray[1]()); then it compiles but the data is wrong either from M2K or RTY

        any ideas?

        thanks in advance

        Richard
        Last edited by richbois; 05-28-2021, 03:01 AM.

        Comment


          #5
          Hello Richard,

          Thanks for your reply.

          For this line: hMA3indi = HMA3indi(BarsArray[1]()); you have an additional () after [1], and I suspect you may be missing a period value for the HMA (Not sure as you are using a custom indicator).

          So perhaps something like: hMA3indi = HMA3indi(BarsArray[1], 14);

          Please note that you would not be able to add a chart indicator based on another data series as advised here: "An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)" Reference: https://ninjatrader.com/support/help...tindicator.htm

          It is possible to manually add an indicator to chart based on another data series and to do that you would have to add the data series manually to the chart data series and (if you wish) hide the data series by setting its bar colors to transparent and setting it panel to be the same as the 1st panel. Please note that with non time-based data series, you may not get an acceptable display. Reference: https://www.youtube.com/watch?v=XRGx...UEYKym&index=3
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Thank you Paul as usual you had the solution with the youtube video that is perfect for me

            Again thank you and have a great weekend

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by BarzTrading, Today, 07:25 AM
            2 responses
            26 views
            1 like
            Last Post BarzTrading  
            Started by devatechnologies, 04-14-2024, 02:58 PM
            3 responses
            20 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by tkaboris, Today, 08:01 AM
            0 responses
            6 views
            0 likes
            Last Post tkaboris  
            Started by EB Worx, 04-04-2023, 02:34 AM
            7 responses
            163 views
            0 likes
            Last Post VFI26
            by VFI26
             
            Started by Mizzouman1, Today, 07:35 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X