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 junkone, Today, 11:37 AM
            2 responses
            14 views
            0 likes
            Last Post junkone
            by junkone
             
            Started by frankthearm, Yesterday, 09:08 AM
            12 responses
            44 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            35 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by proptrade13, Today, 11:06 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            35 views
            0 likes
            Last Post love2code2trade  
            Working...
            X