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 arvidvanstaey, Today, 02:19 PM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        7 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by mmckinnm, Today, 01:34 PM
        3 responses
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X