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

Multinstument problem

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

    Multinstument problem

    I am trying to make a pair strategy in ninjatrader. I am mnot an experienced builder at all, so it could be a very simple solution. Although I can get a chart of the spread I can't seem to understand how to get an order for two different instuments. For instance in this case, where I added ^CAC40 as secondary instrument. This is what i got and is not working.....

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Spread(-20, 2, "^CAC40", true), Bollinger(Spread(-20, 2, "^CAC40", true), SD1, KT).Upper, 1))
    {
    if (BarsInProgress==0)
    { EnterLong(0,Aantal1, "");}
    if (BarsInProgress==1)
    {EnterShort(1,Aantal2, "");}
    }


    }

    #2
    Thank you for your question, dctdave. In order to have a complete picture as far as what is going on, would it be possible to provide your Initialize section, where you set up your second instrument's bars?
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jessica. Below is the initialize section included :

      protected override void Initialize()
      {
      Add(Spread(-20, 2, "^CAC40", true));
      Add(Bollinger(Spread(-20, 2, "^CAC40", true), SD1, KT));
      Add(Spread(-20, 2, "^CAC40", true));

      CalculateOnBarClose = true;
      Add("^CAC40",PeriodType.Day,1);
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(Spread(-20, 2, "^CAC40", true), Bollinger(Spread(-20, 2, "^CAC40", true), SD1, KT).Upper, 1))
      {
      if (BarsInprogress==0)
      {EnterLong(0,Aantal1, "");}
      if (BarsInprogress==1)
      EnterShort(1,Aantal2, "");}
      }

      Comment


        #4
        Thank you for this additional information. While I can not speak to the third party Spread tool you are using, it looks like we may want to change the BarsInProgress index from 1 to 4, since you add your daily ^CAC40 series as your fourth series. If this does not get desired results or there are any questions we may answer please reach out.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thank you for the help. I will try this solution.

          Comment


            #6
            Thanks,you were right. I get now signals for both products.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sidlercom80, 10-28-2023, 08:49 AM
            167 responses
            2,260 views
            0 likes
            Last Post jeronymite  
            Started by warreng86, 11-10-2020, 02:04 PM
            7 responses
            1,362 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Perr0Grande, Today, 08:16 PM
            0 responses
            5 views
            0 likes
            Last Post Perr0Grande  
            Started by elderan, Today, 08:03 PM
            0 responses
            9 views
            0 likes
            Last Post elderan
            by elderan
             
            Started by algospoke, Today, 06:40 PM
            0 responses
            10 views
            0 likes
            Last Post algospoke  
            Working...
            X