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

I want to execute on "touch" of the EMA's...

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

    I want to execute on "touch" of the EMA's...

    I'm trying to assemble the elements of an automation using Strategy Builder in NT8. I'm not good at or very conversant in Pseudo Logic, so I will attempt to explain my needs as simply as possible in plain language.

    I'm using a simple ema crossover strategy with period values at 2-32.

    Setting "Calculate to tick by tick" I want to execute an entry at a price as close as possible to the point where the ema's first touch. The problem is that the tail of the fast ema will touch and re-touch (many times). In simplest terms how can I limit the entry to the first touch only?

    I'd appreciate someone walking me through the steps in Strategy Builder. Thanks in advance for your help.

    John Dent
    Attached Files
    Last edited by NinjaTrader_PatrickH; 02-13-2018, 01:54 PM.

    #2
    Hello chofujohn,

    Thanks for your post and welcome to the NinjaTrader forums!

    You can create and use a bool variable (true or false only) that is set to false before the entry and then is set true after the entry. You would test for the bool to be false in the entry conditions. After the entry, the bool is set to true so the entry condition is no longer valid and no further orders can occur in that set until the bool is reset to false.

    In another set you would need to find a condition that you would use as a reset. (perhaps the opposite direction entry)

    I've attached an example for the entry condition to show how the bool would work. I named it FirstTouch which I have initialized to false. When the order is placed the bool is then set to true and this will prevent any further orders until the bool is reset to false.
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      It's not working...

      Hi Paul,

      Thanks for the response and the solution. However, I've created and invoked the strategy and it's not working. I'm attaching the appropriate Strategy Builder screenshots.
      Attached Files

      Comment


        #4
        Hello chofujohn,

        Thanks for your reply.

        It looks like you are using the same bool in each of the sets. What i would suggest is using a different bool to control each set and then using the opposite set as the reset condition.

        For example, create a bool called bool2 to control set two.
        In Set 1, in the actions section, add the action to set bool2 to false (this is where you are also setting bool1 to true).
        In Set 2, in the conditions section change the condition to check if Bool2 is false (you have bool1 now). In the actions section, add the condition to set bool 2 to true.

        in summary:

        Set 1 conditions Crossabove, test if Bool1 is false
        Set 1 actions: Enter long, set bool 1 true, set bool 2 false

        Set2 conditions Crossbelow, test if bool 2 is false
        Set 2 actions: enter short, set bool2 true, set bool 1 false

        This set-up will prevent a long order until you have placed a short order and vice versa so that may not be what you want. You may have to use some other conditions to reset bool 1 and bool 2 back to false. Another example would be to reset the bool x number of bars after the last entry.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          It's needs more tweaking...

          Hi Paul,

          The trade is triggering now. Thanks. But, as in the example screenshot I'm attaching if the market moves in the opposite direction of the "touch/cross" then there is nothing to keep it from registering huge losses. I call it being "wrong footed". I'm very interested in learning your solution to the problem.

          John
          Attached Files

          Comment


            #6
            Hello chofujohn,

            Thanks for your reply.

            It appears the strategy did as you wish, IE: enter an order on the first cross when using Calculate.OnEachTick. The strategy cannot predict that the next bar would/will reverse so you would need to establish how you want the strategy to react to that situation.

            If the entry was not what you wanted then you would need to implement some other logic criteria to ensure you are getting the entry you wish.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Reaction of strategy AFTER the touch...

              Originally posted by NinjaTrader_Paul View Post
              Hello chofujohn,

              Thanks for your reply.

              It appears the strategy did as you wish, IE: enter an order on the first cross when using Calculate.OnEachTick. The strategy cannot predict that the next bar would/will reverse so you would need to establish how you want the strategy to react to that situation.

              If the entry was not what you wanted then you would need to implement some other logic criteria to ensure you are getting the entry you wish.
              Hi Paul,

              You are absolutely correct. The strategy executed exactly as requested. Thank you very much for your assistance. However, the strategy is not complete and there are additional elements I need to add.

              Please refer to the chart screenshot attachment as it explains exactly what I want.

              Paul, I know you'll get me to my ultimate goal and I want to thank you in advance.

              Best Regards,

              John Dent
              Attached Files

              Comment


                #8
                Hello chofujohn,

                Thanks for your reply.

                I'm sorry, we do not provide coding service. If you would like your strategy coded for you, we can provide references to 3rd party providers for this.

                To continue your understanding of the strategy builder please review the recorded webinar here: https://www.youtube.com/watch?v=HCyt...We0Nf&index=11

                You may also want to attend live strategy builder webinar training, here is a link to sign up: https://ninjatrader.com/Webinar/Strategy-Builder-301
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Coding service????

                  Originally posted by NinjaTrader_Paul View Post
                  Hello chofujohn,

                  Thanks for your reply.

                  I'm sorry, we do not provide coding service. If you would like your strategy coded for you, we can provide references to 3rd party providers for this.

                  To continue your understanding of the strategy builder please review the recorded webinar here: https://www.youtube.com/watch?v=HCyt...We0Nf&index=11

                  You may also want to attend live strategy builder webinar training, here is a link to sign up: https://ninjatrader.com/Webinar/Strategy-Builder-301
                  Just curious, but what do you think you've been doing? I've been providing the logic of what I want to do and you've been providing the coding through Strategy Builder. How is this request ANY different from the service you and others have been providing all along? Please have the department head of tech support contact me via telephone. There are some things I'd really like to discuss. I'm not at all happy. John Dent
                  Last edited by NinjaTrader_PatrickH; 02-13-2018, 01:43 PM.

                  Comment


                    #10
                    Hello chofujohn,

                    Thank you for your response.

                    Attached are the screenshots we discussed in .zip archives.

                    The first ones are the first Condition Set to determine if the position is short and if the bar touched the two EMAs. I used 10 and 20 for the periods of the EMAs.

                    The second ones are the second Condition Set to determine if the prior bar was as the first Condition Set and if the bar is now "red".

                    Please let me know if you have any questions.
                    Attached Files

                    Comment


                      #11
                      I want to execute on "touch" of the EMA's

                      Hello, anybody can help me? I have tried so many times to build my strategy but when the 2 ema's touch and begin to cross the strategy did not excute but dit it on the SECOND bar that is formed!
                      I would like to excute on the same bar when the ema's cross.

                      Comment


                        #12
                        Hello jamalski,

                        Thanks for your post.

                        If you would like your strategy to calculate and place orders the moment a condition becomes true, you would need to use a Calculate mode of OnEachTick.

                        Calculate.OnEachTick will allow the strategy to calculate information for each incoming tick that occurs and place orders intrabar. Otherwise, Calculate.OnBarClose would cause the strategy to only calculate values and place trades at the close of a bar.

                        See this help guide documentation for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

                        Ultimately, to understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                        Below is a link to a forum post that demonstrates how to use prints to understand the behavior of a strategy.
                        https://ninjatrader.com/support/foru...121#post791121

                        Let us know if we may assist further.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #13
                          Ok thanx, and is it possible to wait 30 seconds before placing another entry? i got a good entry but in a second a second entry opened in the other direction!!

                          Comment


                            #14
                            Hello jamalski,

                            Thanks for your note.

                            A timer could be used to have a "delayed event" submit orders after 30 seconds have passed.

                            See the forum thread linked below which contains an example script that demonstrates adding a timer for a "delayed event".

                            Sometimes after adjusting an SL or TP order in the SIM account, it stays on 'ChangePending' and nothing happens anymore. If I try to adjust it again by manually dragging it in the chart, it just snaps back to the previous position. Even after quitting and restarting Ninjatrader the order is still 'Change Pending' and I cannot


                            Let us know if we may assist further.
                            Brandon H.NinjaTrader Customer Service

                            Comment


                              #15
                              Ok thanx, i noticed that my strategy executes entry's without crossing??? And also not at the moment that the ema's in realtime crossing?
                              I made screenshots of the settings.


                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Working...
                              X