• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy builder - multiple entries

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

    Strategy builder - multiple entries

    Based on an older post here https://ninjatrader.com/support/foru...ad.php?t=21796 I tried to create a rule for multiple entries as a backtesting example in the Strategy builder. But I can't make it work. I always get only first entry triggered.

    Condition
    High[0] >= DonchianChannel(Highest).Upper[0]

    Actions
    EnterLongStopMarket(DefaultQuantity,(Default input[0] + 0.1),@"unit1")
    EnterLongStopMarket(DefaultQuantity,(Default input[0] + ((ATR(Close, 10[0] * 0.5) )),@"unit2")
    EnterLongStopMarket(DefaultQuantity,(Default input[0] + ((ATR(Close, 10[0] * 1) )),@"unit3")
    EnterLongStopMarket(DefaultQuantity,(Default input[0] + ((ATR(Close, 10[0] * 1.5) )),@"unit4")

    What's wrong?

    Thank you
    Attached Files
    Last edited by Domek_69; 09-10-2018, 02:30 PM.

    #2
    Hello Domek_69,

    Thank you for the question.

    In this case, because you are submitting multiple entries in one direction, you would also need to change the EntriesPerDirection in the strategies properties. Have you used 4 as the EntriesPerDirection or alternatively used Entry Handling: Unique Entries?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Oh silly me! I forgot to set the number of entries :-). Now it works, but it behaves strangely - entering units in messy order and several times. For example - Order of Unit 1, Order of Unit 1, Order of Unit 2, Order of Unit 1. How can I attach the second screenshot to show it?

      Comment


        #4
        Hello Domek_69,

        You can attach a screenshot in the same way you did with post #1. If you need to edit your existing post, you should be able to click the Edit button at the bottom of the post you want to edit, then you could add a screenshot.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Cheers, I am still new to this forum.
          In the meantime, I found out what causes the problem, but I don't the way around it. The unit one orders are triggered every time my condition is met. So in many cases, this would happen before the second order is triggered (see my second screenshot). Of course, this is because I allowed more orders in one direction. How can I allow only one order per every unit?
          Last edited by Domek_69; 09-12-2018, 02:07 AM.

          Comment


            #6
            Hello Domek_69,

            Thank you for the reply.

            I am not certain I understand how you have worded your question. You noted, "How can I allow only one order per every unit?"
            Are you referring to the unit as the SignalName for the entries you have created? What is the specific end goal you are trying to achieve?

            The logic being used now will submit an order with the specified quantity each time this condition is true.

            After enabling more EntriesPerDirection that would allow for the extra orders to submit but has no control over fills and when the overall condition is true. When your order fills such as the first entry, if your condition becomes true again it will resubmit a new order because that's what you are specifically doing in the logic.

            You may want to look into adding other logic into the condition or splitting up the condition into multiple sets that can become more complex to handle the situation. One way to handle this could be to use the position information. If you are already in a position, don't resubmit the orders as one example. This will, however, change how your orders are being handled. With the managed approach if you do not resubmit the limit/stop type orders on each bar they are expired, so this is an item you can test to see what the results are by making changes.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,
              Sorry for the unclarity. You got it right. I am trying to submit orders when a certain condition is met. In this example when the Highest High condition is met, then first stop order is executed the next day, all other orders are submitted and waiting for the Stop price to be reached to be also executed (few bars later in the attached image)
              I was trying to play with the position information, to stop new Unit 1 orders to be submitted. In the Condition section I used:

              Current Market position != Market position long

              - but then, as you mentioned, orders for unit2 - unit 4 are not resubmitted.

              Maybe Counting Position Size would help?

              Explanation to the image - this is an example how I wanted to set the rules
              - executing orders for unit1, unit2, and unit3. The order for unit 4 is not triggered as the market reverts and goes against the Long orders. All three executed units are closed at the same time.


              Thank you

              Petr
              Attached Files

              Comment


                #8
                Hello Domek_69,

                Thank you for the reply.

                In the image, it appears that you are using a single Trailing Stop that is not associated with a specific entry. Are you wanting the exits to all occur at the same time, or had you intended to have each entry have its own trail stop?

                Regarding the logic, this may be an item where you can to use user variables to denote that you have submitted an order. Because there is no easy way to track the orders in the builder you could use a user variable and a few sets to control the logic. If you only want the entry to submit once, you could use a variable and set it to a specific value after submitting the order. In the condition to submit the order, you would also need to check that variable is not that specific value to allow the condition once. If the condition had already happened it would prevent it from happening again. This could also be reset in your opposing condition to make sure it can become true again once it comes time.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,
                  Yes, I want all the orders to be closed in one "exit". The displayed trailing SL is just a coincidence. I had there also a normal exit condition but it did not work properly in the example.

                  Thank you for the tip with variables. Should think about it myself. Anyway, I am trying to build the logic, which seems to be quite simple (4 separate entries, one exit) and I could not make it work properly. Is there any print function in the builder, like the one advertised in a Ninja script, so I can follow the behavior. The Builder online manual seems to be very simple and I generally did not find too many details regarding the builder. I have just this link https://ninjatrader.com/support/help...on_builder.htm

                  Thank you

                  Petr

                  Comment


                    #10
                    Originally posted by Domek_69 View Post
                    Hi Jesse,
                    Yes, I want all the orders to be closed in one "exit". The displayed trailing SL is just a coincidence. I had there also a normal exit condition but it did not work properly in the example.

                    Thank you for the tip with variables. Should think about it myself. Anyway, I am trying to build the logic, which seems to be quite simple (4 separate entries, one exit) and I could not make it work properly. Is there any print function in the builder, like the one advertised in a Ninja script, so I can follow the behavior. The Builder online manual seems to be very simple and I generally did not find too many details regarding the builder. I have just this link https://ninjatrader.com/support/help...on_builder.htm

                    Thank you

                    Petr
                    Sorry, in the meantime found the print function. However, any other tip and help are welcomed.

                    p.

                    Comment


                      #11
                      Hello Domek_69,

                      Thank you for the reply.

                      Yes, in this case, the builder documentation specifically is fairly light. The builder does have a video which covers most of its features which you can find here: https://youtu.be/HCyt90GAs9k

                      After learning to use the basic menu system in the builder, the NinjaScript manual would actually take place for the builder documentation. Because the builder is simply generating NinjaScript syntax, all of the properties the builder uses are documented in the NinjaScript section.

                      Just to note where it is, there is a Print function, this is found in the Actions under Misc -> Print.
                      You can also use Drawing Objects from the Actions to visually mark the chart to better understand what the logic is doing.

                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by aslane, Today, 02:27 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post aslane
                      by aslane
                       
                      Started by dadarara, Yesterday, 06:38 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by jvanelli, Today, 01:19 PM
                      1 response
                      2 views
                      0 likes
                      Last Post jvanelli  
                      Started by TrendFollowingCapital, Today, 05:45 AM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by Atilla, Today, 04:26 AM
                      1 response
                      15 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X