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 bortz, 11-06-2023, 08:04 AM
            47 responses
            1,607 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            9 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            19 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            6 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            15 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X