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

ExitLong() used multiple times

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

    #16
    Originally posted by koganam View Post
    They do not. There is a nuance that you are missing. EntryHandling.UniqueEntries means that you may make a number of separate entries using the same name, not that it will. Your code path will determine what will happen.
    That is exactly what I have done. I enabled EntryHandling.UniqueEntries = 2 and then I used the code below, BUT my "Long A" entry is still ONLY executed once and not twice as the parameter should indicate.

    My code:
    EntryLong(x, "Long A");
    EntryLong(x, "Long B");
    EntryLong(x, "Long A");

    EntryHandling.AllEntries means that you may enter as many trades as determined by that number, regardless of their names. When the aggregate number of trades reaches that number, you may not enter any more trades, regardless their name.
    Yes, exactly, and it appears that my EntryHandling.UniqueEntries is working just like EntryHandling.AllEntries is supposed to do because it ignores my entry names, such as "LONG A" and "LONG B", and just allows for amount of entries based on my parameter setting.

    Comment


      #17
      Originally posted by warcious View Post
      That is exactly what I have done. I enabled EntryHandling.UniqueEntries = 2 and then I used the code below, BUT my "Long A" entry is still ONLY executed once and not twice as the parameter should indicate.

      My code:
      EntryLong(x, "Long A");
      EntryLong(x, "Long B");
      EntryLong(x, "Long A");
      Does this work?


      Code:
      EntryLong(x, "Long A");
      EntryLong(x, "Long A");
      EntryLong(x, "Long B");


      In order to not fight the system in place, I control all my entries/stops/targets with named entries, and have logic to see what has fired and what has not, etc....

      Comment


        #18
        sledge,

        No, it does not work, and my X is just a number, does not matter if its 1 or 3.
        What I am trying to understand is what does a UniqueEntry mean?

        I though that entry on row 1 and 3 is the same UniqueEntry with the name "Long A", but apparently I am wrong, since both "EntryHandling = EntryHandling.UniqueEntries;" and "EntryHandling = EntryHandling.AllEntries;" will ONLY execute my entry order named "LONG A" only once (1 time), despite if my setting EntriesPerDirection is set to 2, 7, or 13. It ONLY executes "LONG A" once.

        My code:
        EnterLong(1, "Long A")
        EntryLong(2, "Long B");
        EntryLong(3, "Long A");

        That is why I am questioning what UniqueEntry IS, since apparently it is NOT an entry with an unique signal name.

        Comment


          #19
          Originally posted by warcious View Post
          sledge,

          No, it does not work, and my X is just a number, does not matter if its 1 or 3.
          What I am trying to understand is what does a UniqueEntry mean?

          I though that entry on row 1 and 3 is the same UniqueEntry with the name "Long A", but apparently I am wrong, since both "EntryHandling = EntryHandling.UniqueEntries;" and "EntryHandling = EntryHandling.AllEntries;" will ONLY execute my entry order named "LONG A" only once (1 time), despite if my setting EntriesPerDirection is set to 2, 7, or 13. It ONLY executes "LONG A" once.

          My code:
          EnterLong(1, "Long A")
          EntryLong(2, "Long B");
          EntryLong(3, "Long A");

          That is why I am questioning what UniqueEntry IS, since apparently it is NOT an entry with an unique signal name.
          You may need to read a bit more carefully, albeit, even then it is not quite as clear as it could be. " ... NinjaScript will process all order entry methods until the maximum allowable entries set by the EntriesPerDirection property has been reached while in an open position" (emphasis mine).

          What you have written does not put things in an open position, as all three statements will be executed on the same tick, so your second entry is entering in the same condition as the first one.

          Comment


            #20
            Originally posted by koganam View Post
            You may need to read a bit more carefully, albeit, even then it is not quite as clear as it could be. " ... NinjaScript will process all order entry methods until the maximum allowable entries set by the EntriesPerDirection property has been reached while in an open position" (emphasis mine).

            What you have written does not put things in an open position, as all three statements will be executed on the same tick, so your second entry is entering in the same condition as the first one.
            This is not correct, as when I have EntryHandling.AllEntries enabled, then it will execute exactly the amount of Entry orders on the very same tick as you are pointing out, my EntriesPerDirection parameter is set to. If it is set to 1 or 2, then this is the amount of Entry orders that will be executed, no matter what signal name they have etc... and these Entry orders are still not in position if I should follow your advice. So, even if I am "not in position" I will execute exactly the amount of entries that my EntriesPerDirection parameter is set to do.

            My question remains:
            What is a UniqueEntry, and what is the difference between EntryHandling.AllEntries and EntryHandling.UniqueEntries?
            And now a third question comes up, when am I "in position"?

            Comment


              #21
              Originally posted by warcious View Post
              This is not correct, as when I have EntryHandling.AllEntries enabled, then it will execute exactly the amount of Entry orders on the very same tick as you are pointing out, my EntriesPerDirection parameter is set to. If it is set to 1 or 2, then this is the amount of Entry orders that will be executed, no matter what signal name they have etc... and these Entry orders are still not in position if I should follow your advice. So, even if I am "not in position" I will execute exactly the amount of entries that my EntriesPerDirection parameter is set to do.

              My question remains:
              What is a UniqueEntry, and what is the difference between EntryHandling.AllEntries and EntryHandling.UniqueEntries?
              And now a third question comes up, when am I "in position"?
              Then I must not have been clear. You cannot enter 2 entries named the same on the same tick if using unique handling. You can enter 2 entries named "Long A" on different ticks: you can handle any number of entries named differently on the same tick, subject of course to the limits that you have defined.

              Look in your log to see if there is a message about why the second entry named the same as an earlier entry was ignored. Naming entries that way makes no sense to me, so I have never done it. Therefore, I cannot assure you that there will be anything in the log about it: I just make a habit of looking there if I do not see what I expect to see.
              Last edited by koganam; 10-02-2016, 11:44 PM.

              Comment


                #22
                Originally posted by koganam View Post
                Then I must not have been clear. You cannot enter 2 entries named the same on the same tick if using unique handling. You can enter 2 entries named "Long A" on different ticks:
                Ok, this would then explain my issue and put things into perspective! Thanks!

                you can handle any number of entries named differently on the same tick, subject of course to the limits that you have defined..
                Yes, this makes sense with my EntryHandling = EntryHandling.AllEntries setting and then EntriesPerDirection will limit how many entries I would do, and this is how I have programmed it.

                My code:
                Initiliaze()
                EntriesPerDirection = 2; (if this is set to 1, then only the first Entry order "EnterLong(quantity50, "Long 50%")" will be executed).
                EntryHandling = EntryHandling.AllEntries;

                UpdateEntryOrders()
                EnterLong(quantity50, "Long 50%");
                EnterLong(restQuantity, "Long Rest");


                Thank you koganam so much for clarifying this issue for me!

                Comment


                  #23
                  Hello Warcious,

                  Koganam is correct with EntriesPerDirection and EntryHandling explanation, thank you Koganam.

                  In your example 1, while you have EntryHandling.UniqueEntries and EntriesPerDirection=2, the reason you are not entered into a long position 2 times for “Long A” is that you cannot use EnterLong/Short with the same unique name, in the same block, it won’t submit a new order. If your statement was true on the next bar, then EnterLong(1, “Long A”) would submit another buy market (your second entry, regardless if you had EnterLong(1, “Long A”) listed a 2nd time) and put you in a position of long 4 (Long B *2 and Long A*2).

                  In your example two, in order to have all three (A/B/C) to you would want to have EntryHandling.UniqueEntries, and entries per direction =1.

                  Please let us know if you need further assistance.
                  Alan P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by chbruno, Today, 04:10 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post chbruno
                  by chbruno
                   
                  Started by josh18955, 03-25-2023, 11:16 AM
                  6 responses
                  436 views
                  0 likes
                  Last Post Delerium  
                  Started by FAQtrader, Today, 03:35 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post FAQtrader  
                  Started by rocketman7, Today, 09:41 AM
                  5 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by frslvr, 04-11-2024, 07:26 AM
                  9 responses
                  127 views
                  1 like
                  Last Post caryc123  
                  Working...
                  X