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

Using Default Instrument to Trade Another

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

    Using Default Instrument to Trade Another

    Hi,

    I tried going into past threads for information, but I could not access them. Anyway, I would like to use a simple strategy I created in NT7 to mirror exact daily buy/sell signals on a second instrument. For example, I am using my simple strategy with the default bar series (lets say SPY) on a daily time period, but I would like it to show the exact same buy/sell signals triggered by the default (SPY) series but for another instrument I choose, such as UPRO. I tried adding another bar series, but no matter what I try, its like the strategy is running separately for the second series instead of just mirroring the buy/sell signals of the default.

    Any help is appreciated.

    Thanks,

    Lee

    #2
    Hello,
    Can you provide a snippet from you code on how you are submitting the orders to the primary and secondary data series?
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      I never got the secondary to work. I only have the primary right now using the EnterLong(Default, "SPY") option and the same for exiting.

      I can attach a snippet later tonight. Do you have a recommended approach?

      Comment


        #4
        Hello,
        I would recommend reviewing the SampleMultiInstrument strategy built into NinjaTrader, This strategy is a reference sample on how to submit orders to multiple instruments. You can review this by going to Control Center > Tools > Edit NinjaScript > Strategy > Select SampleMultiInstrument > Press OK.

        Please let me know if you have any questions after reviewing this sample.
        Cody B.NinjaTrader Customer Service

        Comment


          #5
          So I reviewed the SampleMultiInstrument strategy you suggested, but I don't really want to submit orders to multiple instruments per se, I want the secondary bars object I added to just mimic the buy/sell of the primary. So basically, if the primary instrument says to Enter long on 6/6, I want the secondary instrument to Enter long on 6/6 as well. I don't want the logic to be applied to the secondary (added) bars object. But I'm not sure how to go about this. So here is what I have:

          protected override void Initialize()
          {
          Add("UPRO",PeriodType.Day,1);
          }

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if ( (CrossAbove(SMA(MA1), SMA(MA2), 1)))
          {

          EnterLong(DefaultQuantity, "");
          EnterLong(1, DefaultQuantity, "");

          }

          So I have a single chart that has two data series using two separate panels. I apply my strategy to the first panel with the primary data series being SPY. The second data series is UPRO on panel 2. So if the logic for SPY says EnterLong, I want the secondary (panel 2) to follow the primary and not apply the logic to the second data series. With the (BarsInProgress != 0), it doesn't seem to do anything with regard to the second data series. If I remove this, then it does show buy and sells on the second panel, but the buy/sells do not match the primary as if the logic is being applied to the second data series as well.

          So how would you suggest I go about this?

          Thanks,

          Lee
          Last edited by lee612801; 06-06-2016, 08:25 PM.

          Comment


            #6
            Hello,
            This code should work as expected if you use a different signal name for the EnterLong for the secondary data series.
            Please let me know if you do not see it work as you are expecting it after using a different signal name.
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Yep, that worked. Thank you!

              One more question, is there a way to separate the two series results when using the strategy analyzer? It combines the series when calculating the cumulative profit.

              Thanks,

              Lee

              Comment


                #8
                Hello,
                If the strategy is a multi instrument strategy you would not be able to split the results in the strategy analyzer. If you are using an instrument list when backtesting this way you will have results for each instrument backtested on in the instrument list seperated.
                Cody B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by magnatauren, 08-15-2020, 02:12 PM
                5 responses
                206 views
                0 likes
                Last Post RaddiFX
                by RaddiFX
                 
                Started by rene69851, 05-02-2024, 03:25 PM
                1 response
                21 views
                0 likes
                Last Post rene69851  
                Started by ETFVoyageur, Yesterday, 07:05 PM
                5 responses
                45 views
                0 likes
                Last Post ETFVoyageur  
                Started by jpeep, 08-16-2020, 08:31 AM
                13 responses
                487 views
                0 likes
                Last Post notenufftime  
                Started by realblubb, 04-28-2024, 09:28 AM
                2 responses
                32 views
                0 likes
                Last Post realblubb  
                Working...
                X