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

EntriesPerDirection in Multi-Instrument strategy

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

    EntriesPerDirection in Multi-Instrument strategy

    My strategy has the code within OnBarUpdate()


    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][COLOR=blue][FONT=Verdana]for[/FONT][/COLOR][COLOR=black][FONT=Verdana]([/FONT][/COLOR][COLOR=blue][FONT=Verdana]int[/FONT][/COLOR][COLOR=black][FONT=Verdana] i = [/FONT][/COLOR][COLOR=purple][FONT=Verdana]0[/FONT][/COLOR][COLOR=black][FONT=Verdana]; i < instruments; i++)[/FONT][/COLOR][/COLOR][/SIZE]
    [COLOR=#0000ff][SIZE=2][COLOR=#282828][FONT=Verdana] { [/FONT][/COLOR][/SIZE]
    [SIZE=2][COLOR=#282828][FONT=Verdana]  if(Positions[i].MarketPosition == MarketPosition.Flat)[/FONT][/COLOR][/SIZE]
    [SIZE=2][COLOR=#282828][FONT=Verdana]             EnterLong(i, shares,"MyStrategy LONG");[/FONT][/COLOR][/SIZE]
    [SIZE=2][COLOR=#282828][FONT=Verdana]  }[/FONT][/COLOR][/SIZE][/COLOR][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    If I have EntriesPerDirection = 1, does this mean the long entry for only my first instrument will be executed?

    Or does it mean that only one long entry per instrument will be executed?

    [The above for NT 6.5]
    Last edited by AnotherTrader; 12-22-2010, 10:23 AM.

    #2
    Hello AnotherTrader,

    EntriesPerDirection is based on the signal name of the entries, and works closely with EntryHandling property.

    If set to 1 it only allows one entry per signal name with unique handling.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hello AnotherTrader,

      EntriesPerDirection is based on the signal name of the entries, and works closely with EntryHandling property.

      If set to 1 it only allows one entry per signal name with unique handling.
      So, in my example, the only entry would be the long entry for my first instrument (i.e. the one with BarsInProgress = 0)?

      Comment


        #4
        Yes, that's correct. EntriesPerDirection is based on rules in the whole strategy, and not per instrument.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          Yes, that's correct. EntriesPerDirection is based on rules in the whole strategy, and not per instrument.
          ... and so I guess if I set EntriesPerDirection equal to the number of instruments, then there could be an entry for each instrument?

          Comment


            #6
            That's one way to do it. You can also leave it at 1 but set EntryHandling to unique entries. You can then tag your entries as unique with something like this:


            for(int i = 0; i < instruments; i++)
            {
            if(Positions[i].MarketPosition == MarketPosition.Flat)
            EnterLong(i, shares,"MyStrategy LONG" + i);
            }
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks! That worked really well.

              Comment


                #8
                Am continuing to work through this, and have the following code incorporated:

                Code:
                 
                for(int i = 0; i < instruments; i++)
                { 
                if(Positions[i].MarketPosition == MarketPosition.Flat)
                EnterLong(i, shares,"MyStrategy LONG" + i);
                }
                If I am working with daily bars for 3 instruments (so OnBarUpdate() gets evaluated for BarsInProgress = 0, 1 and 2), and if I evaluate the above code during BarsInProgress = 1, i.e. ...

                Code:
                 
                If(BarsInProgress == 1)
                {
                for(int i = 0; i < instruments; i++)
                { 
                if(Positions[i].MarketPosition == MarketPosition.Flat)
                EnterLong(i, shares,"MyStrategy LONG" + i);
                }
                }
                ... it seems that the entry happens on the same day for instruments 1 and 2, but on the next day for instrument BIP = 0 (I guess as OnBarUpdate() has already been evaluated for instrument BIP = 0?).

                Any suggestions as to how I can get instrument BIP = 0 to enter on the same day?

                Comment


                  #9
                  What are the three time frames you're using?
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_RyanM View Post
                    What are the three time frames you're using?
                    All instruments use just daily bars.

                    Comment


                      #11
                      Do you get better results when using if (BarsInProgress == 0) for your condition?

                      You also might want to try this in 7 as multi series strategies have changed since 6.5. I'm getting 3 entries on the same day with 7 using a similar setup.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bortz, 11-06-2023, 08:04 AM
                      47 responses
                      1,606 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