Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Series and Secondary Series into a Strategy

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

    Price Series and Secondary Series into a Strategy

    I have been reading through code over the last few days for creating trading logic for a price series (if I am referencing the correct name) and a secondary series for also submitting trades to that instrument based off the primary series signal.

    Price Series

    I am hoping to look at the close prices to make sure my candles are trending for instance. I understand how to create this when referencing other indicators in my code but that is not always accurate with the system. So, let's say the logic would be close[0]>close[1]>close[2]>close[3]. I would want 3 candles needing to be closed higher than the previous.

    NinjaTrader 8​ - Would this link be where I need to use the Iseries and create those variables. Or is there any code online anyone has seen has a basic indicator does something similar where I could then manipulate the indicator and then just reference the code since I could manage that much easier.

    Secondary Series

    I have looked at a bunch of code for this but it is just above me at this point. It does not look that complicated but I have been recommended areas to view the code. I essentially want to use my current system I trust that takes its signals from ES and then immediately submit a market order on NQ at the same time.

    NinjaTrader 8​ - This is the code I felt like made the most sense for this but I am not sure if it is as easy as just copying and pasting what is needed to then make sure bars in progress reference the secondary series?

    #2
    Hello, thanks for writing in.

    For a price series, you would need to use the Series<t> object to make a Series<double> collection. These custom series will have a slot index for every bar on the chart so they are convenient to use for data storage. We have an example to reference here.

    On the secondary series, The help guide shows how to submit an order on the secondary series by using the BarsInProgress index which indicates which bar series OnBarUpdate is being called for. You do not need to use this method because we have an order overload on all entry orders that takes a barsInProgressIndex parameter e.g.

    Code:
    EnterLong(int barsInProgressIndex, int quantity, string signalName);
    To enter ES and NQ (with NQ being an added data series)

    Code:
    EnterLong(0, 1, "ESENTRY");
    ​EnterLong(1, 1, "NQENTRY");

    Comment


      #3
      great to hear the price series is pretty much what I expected.

      for the secondary series does this mean the conditions for ES also need to be true for NQ for it to enter? I didn't think that was the case but just wanted to make sure. I have added a few pieces to the code for the data series but it is not trading since I have a couple variables I need to remove before seeing if I have everything else right

      Comment


        #4
        Hi, if you call both EnterLong() methods one after the other in the same condition group then they will both enter (set EntriesPerDirection = 2). Its up to your code if the condition for the ES also triggers the NQ order, you can separate them if you wish.

        Comment


          #5
          NinjaTrader_ChrisL is it possible to keep the entry condition grouped in the condition but change its exit since it seems to still be tied to ES. To clarify, ES signal sends to ES and NQ. Then ES signal sends to ES only for exit and NQ uses its own set profit target and stop loss not linked to the move on ES

          Comment


            #6
            Hello, thanks for the follow up. You may use these entry/exit overloads to target a specific series:
            EnterLong(int barsInProgressIndex, int quantity, string signalName)
            ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)

            if ES is primary (the instrument on the chart) and the NQ is secondary, you would use 0 for the barsInProgressIndex to target ES and 1 for barsInProgressIndex to target NQ.

            Comment


              #7
              NinjaTrader_ChrisL Thanks! I finally figured it out, I was accidentally referencing the ES contract in one of the other areas I missed. Is there a way to create a box in the strategy tab when it's added to a chart where I can change the secondary data series without going into the code? If not, I guess I just need to make sure I manually change it each quarter.

              Comment


                #8
                Hi, that would not be possible because AddDataSeries() needs to be called in the State.Configure state, within OnStateChanged. It is only added once during initialization.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                50 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                126 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                69 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                42 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X