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

How can I set this strategy up?

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

    How can I set this strategy up?

    I want to place a stop limit buy order with a stop loss once I have the position, and if I am out of the position because the stop loss is triggered I can automatically renter position if it reaches price point again?

    For Example:

    Lets assume current ES price is 390 and I place a buy stop limit order to enter ES future at 4000, and then have stop loss at 3999, and then price hits 4000 and it buys, then it hits 3999 and then it sells, however now I have no position, and then price hits 4000 again I would like for it to buy that position again with same stop loss at 3999. So basically if it hits $4000 i want to own that position for x number of contracts and if it falls below 3999 it automatically pulls me out.

    Any help on this would be greatly appreciated!

    #2
    Hello Azizmd2020,

    Thanks for your post.

    You could create a condition that checks if the Position.MarketPosition is equal to MarketPosition.Flat and checks if the current market price (Close[0]) is greater than or equal to a numerical value and call EnterLongStopLimit() to place a buy stop limit order at the price you want. You could track that order in OnExecutionUpdate() to determine if the state of the order is filled and call your stop loss order method, ExitLongStopMarket() or ExitLongStopLimit().

    This would mean that the strategy would place a buy stop limit order when you are in a flat position and the current market price is above a specific value. Then, when the buy stop limit order is filled, the strategy would place the stop loss using an Exit method. When that Exit method is filled, you will be in a flat position and this would allow the condition to place to buy stop limit order to become true again to place that order, and so on.

    See the help guide documentation below for more information and sample code.

    Managed Approach Order Methods: https://ninjatrader.com/support/help...d_approach.htm
    Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm
    OnExecutionUpdate(): https://ninjatrader.com/support/help...tionupdate.htm

    And, see this reference sample demonstrating the use of OnExecutionUpdate(): https://ninjatrader.com/support/help...and_onexec.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Great Thank you so much Very helpful!

      Comment


        #4
        @NinjaTrader_BrandonH​ Another quick question, I would like to buy the position at a certain price at market and not with out a limit when i initially enter a position, so to quote you from above

        "This would mean that the strategy would place a buy stop limit order when you are in a flat position" instead I would like to place a buy stop at market once it hits a certain price. is that possible?

        Comment


          #5
          Hello Azizmd2020,

          Thanks for your note.

          If you would like to place a buy stop order when a certain price is reached, a condition could be created that checks if the current close price (Close[0]) is greater than or equal to a numerical value and call the EnterLongStopMarket() method.

          EnterLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm

          Let me know if I may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Is there a way to contact you for one on one phone support brandon? can you message me if possible?

            Comment


              #7
              Hello Azizmd2020,

              Thanks for your note.

              With NinjaScript and Strategy Builder related items, we find that working through email is best for our NinjaScript Support team.

              This gives our Support team time to research and test your inquiry to ensure we have the best information available for you. Through email, we are able to provide example code snippets, attach example scripts and links to samples on the forum, and provide educational resources such as videos and links in our help guide.

              Our calls are kept to approximately 20 minutes and we find that calls for NinjaScript can easily surpass our allotted time for a call, as NinjaScript questions can be complex.

              ​We also cannot assist with creating, debugging, or modifying a script on your behalf. This means that if we are on the phone and you have questions about the logic of your script, we would need to end the call and assist with the process through email.

              If you have further questions related to creating or debugging strategy logic, you could post your questions here or write in to scriptingsupport[AT]ninjatrader.com with your questions and we will be happy to provide further direction.

              Let me know if I may further assist.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Hi NinjaTrader_BrandonH​, your help has been amazing so far, so here is my question when you say I can create a condition that checks if the Position.MarketPosition is equal to MarketPosition.Flat, how do I actually do that? I use the strategy builder and go through conditions or are you referring to creating actual code?

                The same question applies into how I can do this condition below:

                and checks if the current market price (Close[0]) is greater than or equal to a numerical value and call EnterLongStopLimit() to place a buy stop limit order at the price you want.

                Comment


                  #9
                  Hello Azizmd2020,

                  Thanks for your note.

                  You could use the Strategy Builder Conditions and Actions screen to create a condition that checks if the 'Current market position' (Strategy folder > Current market position) is Equal to MarketPosition.Flat (Strategy folder > Market position > Flat).

                  See this image demonstrating this concept: https://brandonh-ninjatrader.tinytak...N18yMDU1NTE5MQ

                  "and checks if the current market price (Close[0]) is greater than or equal to a numerical value"

                  On the left side of the condition builder, select the Price folder > Close. Set the center drop-down menu to 'Greater equal'. On the right side of the condition builder, select the Misc folder > Numerical value > set your numerical value property. In the actions section of the Conditions and Actions screen, call 'Enter long position by stop limit'.

                  See the help guide documentation below for more information about creating conditions in the Strategy Builder: https://ninjatrader.com/support/help...on_builder.htm

                  See this help guide page about how to enter a market position using the Strategy Builder: https://ninjatrader.com/support/help...MarketPosition

                  Let me know if I may assist further.
                  Brandon H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by maybeimnotrader, Today, 05:46 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post maybeimnotrader  
                  Started by quantismo, Today, 05:13 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post quantismo  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  8 responses
                  167 views
                  0 likes
                  Last Post jeronymite  
                  Started by cre8able, Today, 04:22 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post cre8able  
                  Started by RichStudent, Today, 04:21 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post RichStudent  
                  Working...
                  X