Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 data inputs in 1 strategy

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

    2 data inputs in 1 strategy

    Hallo,
    I Have this problem:

    for checking a trend in my strategy it should check the index and the stock with the same parameter at same time.
    How can i programming this? And how can i change the datainput?
    this ist the code: the close from the index and from the stock are the basis:

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] > WMA(54)[0]
    && Close[0] < Open[0])
    {
    CandleOutlineColor = Color.Red;
    EnterLongLimit(DefaultQuantity, High[0], "");
    }

    // Condition set 2
    if (Close[0] < WMA(54)[0])
    {
    ExitLong("", "");
    }
    }

    Thanks Blackburn

    #2
    Hello Blackburn,

    Thanks for the post and welcome to our forums.

    You have to add additional series in the strategies Initialize() method. There are samples built in to the platform to work from and documentation for multiseries scripts is available here:


    Below is how your entry condition might look in a multiseries script.

    Code:
    if (BarsInProgress == 0)
    {
    if (Close[0] > WMA(54)[0]
    && Close[0] < Open[0]
    && Closes[1][0] > WMA(Closes[1], 54)[0]
    && Closes[1][0] < Opens[1][0])
    {
    CandleOutlineColor = Color.Red;
    EnterLongLimit(DefaultQuantity, High[0], "");
    }
    }
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hallo,

      thanks für the fast response.
      Pleas say me, how i can assign / set "close" and "closes" in the code (f.e. stock and index).
      Im using the wizard.

      Blackburn


      Originally posted by NinjaTrader_RyanM View Post
      Hello Blackburn,

      Thanks for the post and welcome to our forums.

      You have to add additional series in the strategies Initialize() method. There are samples built in to the platform to work from and documentation for multiseries scripts is available here:


      Below is how your entry condition might look in a multiseries script.

      Code:
      if (BarsInProgress == 0)
      {
      if (Close[0] > WMA(54)[0]
      && Close[0] < Open[0]
      && Closes[1][0] > WMA(Closes[1], 54)[0]
      && Closes[1][0] < Opens[1][0])
      {
      CandleOutlineColor = Color.Red;
      EnterLongLimit(DefaultQuantity, High[0], "");
      }
      }

      Comment


        #4
        Close is the primary series - the one you run the strategy against. Closes[1] is the first added series. You must unlock code (not possible in strategy wizad) to add additional series.

        Look at the sample multi instrument to start from. Click Tools > Edit NinjaScript > Strategy > Open SampleMultiInstrument.

        Review the documentation on multiseries scripts here:
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        66 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        41 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        24 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        27 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        53 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X