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 cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X