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

Multiple entries

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

    Multiple entries

    I'm about to code a forex strategy that has a potentially unlimited number of orders. I'm wondering about the best way to organize and manage the trades.

    Say I want to buy every pip decrease for the next 20 pips. What's the best way to handle this programmatically? Create a new name for the order at each level or is there a way to dynamically update the number of trades allowed in the same direction?

    #2
    Hello texasnomad,

    EntriesPerDirection is not meant to be dynamic. You should set once in Initialize.


    For this type of strategy, you can consider a couple different approaches.
    • Create a separate entry rule for each potential entry. EntryHandling would be set to unique entries and you would have a uniquely named rule for every entry you want. EntriesPerDirection is set to 1.
    • Use one entry name, but change entry handling to all entries. You then control the number of entries allowed in a direction with EntriesPerDirection property.
    In both cases if you want to dynamically control the number of entries, then this should be handled with your own code. You can increase a counter at some point and run checks against this before executing the entry statements.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hello texasnomad,

      EntriesPerDirection is not meant to be dynamic. You should set once in Initialize.


      For this type of strategy, you can consider a couple different approaches.
      • Create a separate entry rule for each potential entry. EntryHandling would be set to unique entries and you would have a uniquely named rule for every entry you want. EntriesPerDirection is set to 1.
      • Use one entry name, but change entry handling to all entries. You then control the number of entries allowed in a direction with EntriesPerDirection property.

      In both cases if you want to dynamically control the number of entries, then this should be handled with your own code. You can increase a counter at some point and run checks against this before executing the entry statements.
      Ok. So I can set EntriesPerDirection to a really high value that I'll never use (e.g., 200) and then use my counter to loop through the open tickets. Will a value that high cause any problems if I start opening 100+ tickets?

      What type of object will I loop through? I don't see anything in the docs that lets me return a collection with each of my trade tickets for a given instrument.

      Comment


        #4
        Yes, that's one way to do it. You're then effectively managing this property on your own.

        We can't really advise a specific implementation for you. You can work with various events related to orders through the IOrders interface. You could increase your counter when orders are filled, for example.

        One of our members shared an order management system for unmanaged orders, and you may be able to get ideas there. This is posted here:
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the link. I'll look that over in a few minutes.

          I'll try making my own collection of iOrder objects and looping through those.

          I appreciate the suggestions - very helpful.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kempotrader, Today, 08:56 AM
          0 responses
          4 views
          0 likes
          Last Post kempotrader  
          Started by kempotrader, Today, 08:54 AM
          0 responses
          3 views
          0 likes
          Last Post kempotrader  
          Started by mmenigma, Today, 08:54 AM
          0 responses
          1 view
          0 likes
          Last Post mmenigma  
          Started by halgo_boulder, Today, 08:44 AM
          0 responses
          1 view
          0 likes
          Last Post halgo_boulder  
          Started by drewski1980, Today, 08:24 AM
          0 responses
          3 views
          0 likes
          Last Post drewski1980  
          Working...
          X