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

Build strategy which can take entry and exist

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

    Build strategy which can take entry and exist

    Lets say current ES point is 4410, I want to play LONG at 4405 so I will place order and wait for order to reach 4405.

    I want to build strategy for ES, which has below parameters to average second entries when price reaches $5 point view from first entry and 3rd time entry when price reaches $10 move from first entry

    First No of Entries: 1
    First Profit Ticks: 8 ticks
    Second No of Entries: 3
    Second Profit Ticks: 8 ticks
    Second Entry Average Area: 5$ point move from First Entry
    Third No of Entries: 6
    Third Profit Ticks: 8 ticks
    Third Entry Average Area: 10$ point move from First Entry


    #2
    Hello surya,

    The Point value of the ES is 50. The TickSize is .25. Each tick (the minimum price fluctuation) is $12.5.

    To submit an entry with a quantity of 1.
    EnterLong(1, "entry1");

    To submit an entry with a quantity of 3.
    EnterLong(3, "entry2");

    To submit an exit limit at 8 ticks in OnExecutionUpdate():

    ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice - 8 * TickSize, "exit1", "entry1");

    To submit an exit limit at 8 ticks in OnExecutionUpdate();

    ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice - 8 * TickSize, "exit2", "entry2");

    Below are links to examples of stops and targets.
    https://ninjatrader.com/support/foru...80#post1077380
    https://ninjatrader.com/support/foru...596#post806596
    https://ninjatrader.com/support/foru...269#post802269

    As well as a link to a forum post with helpful information about getting started with NinjaScript and C#.
    https://ninjatrader.com/support/foru...040#post786040
    Last edited by NinjaTrader_Jim; 05-13-2022, 12:08 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Please answer below questions
      1) Will this strategy show up in ATM/DOM.
      2) My 2nd entry LONG should only trigger
      2a) if price is moving against my 1st LONG.
      2b) If my 1st TARGET met, then 2nd entry should not trigger.

      Comment


        #4
        Hello surya,

        NinjaScript Strategy stop losses and profit targets do not show as Atm Strategies in the Atm drop-down.
        Chart Trader and the SuperDOM will show any working orders submitted to the selected Account on that instrument including manually submitted orders and orders from a NinjaScript Strategy.

        It is possible to use advanced Atm Strategy methods from a NinjaScript Strategy. Included with NinjaTrader is the SampleAtmStrategy which demonstrates.


        Where you have asked:
        "My 2nd entry LONG should only trigger"

        I'm not sure what the question is here. Both entries should be submitted if the code is called and EntriesPerDirection is 2.

        Where you have asked:
        "if price is moving against my 1st LONG."

        Are you asking how to find if the Position.GetUnrealizedProfitLoss() returns a negative PnL value?


        Where you have asked:
        "If my 1st TARGET met, then 2nd entry should not trigger."

        You can require the Position.MarketPosition to be MarketPosition.Long to allow the second entry. If the position was exited, the position would be flat and the condition would be false and not allow for the second entry.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Looks at this todays live market manual trades. This is how I did, using ATM/DOM.
          1) When market opened, I know my entry point so I placed my 1st entry at 4465.75 using DOM. I patiently waited for PRICE to reach my entry.
          2) As soon as my 1st entry triggered, ATM started showing my TARGET/LOSS lines. Price didn't reach my TARGET, rather it went down.
          3) I know my 2nd entry (blue line), as soon as price reached blue line I placed 3 more additional entries.
          4) So now, I changed my TARGET/LOSSES & booked profits.

          If you see these above 4 steps, I want to achieve with ATM/STRATEGY. So I know I don't have to do it manually. Let me know how can we achieve this.



          Click image for larger version

Name:	Capture.JPG
Views:	230
Size:	28.3 KB
ID:	1198203

          Comment


            #6
            Hello surya,

            Are you currently developing a NinjaScript Strategy in C#?

            What code do you currently have that is not behaving as expected?

            Are you trying to make a condition for the first entry order?

            Are you trying to make a condition to draw a blue line?

            Are you trying to make a condition to submit a second entry order when the position is a loss by a certain amount of ticks?

            Below I am providing a link to a forum post with helpful resources on getting started with NinjaScript and C#.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Are you currently developing a NinjaScript Strategy in C#? ==> NO

              What code do you currently have that is not behaving as expected? ==> NO

              Are you trying to make a condition for the first entry order? ==> NO CONDITION, I KNOW PRICE RANGE. I SET BUY ORDER THROUGH DOM AND WAIT FOR IT TO FILL.

              Are you trying to make a condition to draw a blue line? NO WE DONT NEED TO DRAW BLUE LINE. THE BLUE IS FOR MY MANUAL TRADE WHEN PRICE REACHES 5$ AWAY FROM MY 1ST ENTRY TO AVERAGE.

              Are you trying to make a condition to submit a second entry order when the position is a loss by a certain amount of ticks? ITS JUST $5 AWAY FROM MY 1ST ENTRT

              Below I am providing a link to a forum post with helpful resources on getting started with NinjaScript and C#.==> I DON'T WANT TO BUILD ANY C# IF I CAN ACHIEVE IT THROUGH ATM/STRATEGY BUILDER.

              Comment


                #8
                Hello surya,

                Using the Strategy Builder would still be developing a NinjaScript Strategy.

                However, Atm Strategy methods cannot be used in the Strategy Builder.

                You would need to unlock the script and code this by hand, if you must use Atm Strategy methods.

                If you were to code the logic with exit orders and entry orders, without Atm Strategy methods, this could be done in the Strategy Builder.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Team,

                  Can you please help me build what I'm looking for.

                  Comment


                    #10
                    Hello Surya,

                    I would recommend using the Strategy Builder and starting with the tutorial below and the Conditions and Actions examples to see how various conditions and actions can be made.

                    Strategy Builder 301 (publicly available resource) — https://www.youtube.com/watch?v=_KQF2Sv27oE
                    Written Tutorials - https://ninjatrader.com/support/help..._cross_ove.htm
                    Conditions examples —https://ninjatrader.com/support/help...on_builder.htm
                    Actions examples — https://ninjatrader.com/support/help...us/actions.htm

                    After getting familiar with the various conditions and actions, create a strategy that allows multiple entries (Set EntriesPerDirection/EntryHandling so you may make multiple entries)
                    • Use unique signal names for each entries and exits.
                    Then when making the condition to place the second order, make a condition that uses Misc > "Bars since exit" (BarsSinceExitExecution) to look up when a specific exit has executed. (This will place the next entry order after the first has exited.)

                    BarsSinceExitExecution - https://ninjatrader.com/support/help...texecution.htm

                    EntryHandling - https://ninjatrader.com/support/help...ryhandling.htm

                    EntriesPerDirection - https://ninjatrader.com/support/help...rdirection.htm
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Team,

                      I'm kind of lost and unable to make any progress. Can you please share starting point which I can take into next level.
                      Please share the initial version for me to start.



                      Comment


                        #12
                        Hello surya,

                        The starting point would be to watch the 'Automate Your Trading with NinjaTrader's Strategy Builder' training video linked below.
                        Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.


                        Where you have stated:
                        "Please share the initial version for me to start"
                        I'm not quite understanding what you are asking for. Have you posted an initial version of a script that you have made changes to?

                        To assist, I have provided links to working examples for you to learn from in post #2.

                        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by mjbatts91, Yesterday, 04:48 PM
                        2 responses
                        23 views
                        0 likes
                        Last Post mjbatts91  
                        Started by pibrew, Today, 06:10 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by actualfacts.2021, 07-25-2021, 03:11 PM
                        8 responses
                        1,183 views
                        0 likes
                        Last Post linkcou
                        by linkcou
                         
                        Started by reynoldsn, Today, 07:11 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post reynoldsn  
                        Started by needsomehelp147, 04-29-2024, 06:43 AM
                        2 responses
                        20 views
                        0 likes
                        Last Post needsomehelp147  
                        Working...
                        X