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

Enter as soon as it touch

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

    Enter as soon as it touch

    Hi
    hope you guys having a killer week.
    How do you enter a trade as soon as it touch? For example enter long as soon as 9ema touch 20ema.

    I'm doing this on strategies builder so please make it as simple as you can.
    Thank you

    #2
    Hello SuperDude123,

    Attached are screenshots of how this would appear.

    Below is a link to a forum post with helpful information about getting started with NinjaScript. Please watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' training video.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for replying. Here I have another problem. Once the trade enter and it take profit on the same candle, it enter another trade because I guess it's still in the same candle. How do I avoid that? I did have it set up so the first trade I enter would finish first. But NQ move so fast that all this happen in the same candle

      Comment


        #4
        Hello SuperDude123,

        In the Strategy Builder having an action once would require using a bool and an int variable.

        Below is a link to a forum post with written steps.
        I know technically every price change the computer is registering that the previous bar has closed. But I have some bools and other functionality that need to be reset after the current bar officially closes. Is it possible to do that in an "On price change" strategy?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I' set everything up the way sample have it. But I was unable to find these 2 thing on my list. Any idea why? I set the way it show but when I go chose from the list, it's not there
          Attached Files

          Comment


            #6
            Hello SuperDude123,

            IsFirstTickOfBar is not available in the Strategy Builder. I have provided you a link to a workaround in post #4.
            Did you review this?
            Are you finding this is inadequate?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              If its an Input (like your picture says) then they'll appear under the Conditions section only
              If its a variable, it'll appear under both Conditions and Actions
              Last edited by ezrollin; 10-04-2021, 10:08 PM.

              Comment


                #8
                I dont know what your picture is referencing but maybe this is what they meant???
                Click image for larger version

Name:	1.png
Views:	275
Size:	33.1 KB
ID:	1173578

                Click image for larger version

Name:	2.png
Views:	268
Size:	33.0 KB
ID:	1173579


                Click image for larger version

Name:	3.png
Views:	266
Size:	35.8 KB
ID:	1173580
                I dont know why its supposed to be on set 1 and 2

                Comment


                  #9
                  Thanks a lot for your help. I actually got it just like you. But it doesn't seem to work. It still enter multiple time in one candle, if that candle is big.

                  Basically I set my profit / stop loss at 10 and 10. So if you have a 30 points candle, it would take profit and get back in again on the same candle. I'm trying to avoid that.

                  Comment


                    #10
                    You could use something like
                    If BarsSinceExit == 0
                    {
                    dont start a new position
                    }
                    Maybe that would work?

                    Comment


                      #11
                      I ended up doing this:
                      if ((BarsSinceEntryExecution(0, "", 0) != 0)
                      && (Position.MarketPosition == MarketPosition.Flat))
                      { go long }

                      but I'm not sure if thats the correct way to do it? (BarsSinceEntryExecution != 0)
                      I'd like to know what the officials think?

                      Comment


                        #12
                        Hello ezrollin,

                        BarsSinceEntryExecution will be 0 if the entry is made intrabar, and BarsSinceEntryExecution is called intrabar. What you suggest to control multiple entries in one bar would be plausible.

                        We always suggest to use debugging prints so you can better understand the code that is executing and how you can write specific pieces of logic for your strategy. Checking how BarsSinceEntryExecution prints can confirm your theory.

                        Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk
                        JimNinjaTrader Customer Service

                        Comment


                          #13

                          if I was using BarsSinceEntryExecution would it go based on ticks and not bars since I'm set to calculate on each tick?
                          So Bars would be an incorrect title? thanks
                          Last edited by ezrollin; 10-31-2021, 08:15 AM.

                          Comment


                            #14
                            Hello ezrollin,

                            BarsSinceEntryExecution() would still be a number of bars since the last execution, where the currently building bar is now the most recent bar.

                            Below is a link to the help guide on how bar data is referenced.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by love2code2trade, 04-17-2024, 01:45 PM
                            4 responses
                            31 views
                            0 likes
                            Last Post love2code2trade  
                            Started by cls71, Today, 04:45 AM
                            2 responses
                            10 views
                            0 likes
                            Last Post eDanny
                            by eDanny
                             
                            Started by proptrade13, Today, 11:06 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post proptrade13  
                            Started by kulwinder73, Today, 10:31 AM
                            1 response
                            10 views
                            0 likes
                            Last Post NinjaTrader_Erick  
                            Started by RookieTrader, Today, 09:37 AM
                            3 responses
                            15 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X