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

Place pending buy order with strategy builder

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

    Place pending buy order with strategy builder

    hello
    im in the progress of switching to ninjatrader
    im trying to create a strategy with strategy builder, when conditions are met to place a pending buy stop or enterlongstop order at the indicator value of the swing indicator and then cancel the stop order if the swing indicator has plotted a new value

    #2
    Hello cecilinvest,

    Thanks for your post.

    A strategy builder created strategy will run under what is called the Managed Approach. From the help guide on Managed Approach, "The Managed approach in NinjaScript is designed to offer the greatest ease of use for beginner to intermediate programmers. The order methods are wrapped in a convenience layer that allows you to focus on your system's trading rules, leaving the underlying mechanics of order management and the relationships between entry orders, exit orders, and positions to NinjaTrader. This approach is best suited for simple to moderate order complexity, and can be further broken down into a Basic/Common Managed approach and a more Advanced Managed approach. https://ninjatrader.com/support/help...d_approach.htm

    One of the key points is: "By default, orders submitted via Entry() and Exit() methods automatically cancel at the end of a bar if not re-submitted" So you would not be able to cancel an order directly but you do cancel it by not resubmitting it. You would have to continue to resubmit the order until it either fills or the condition to enter is no longer valid. One way to accomplish resubmitting is to, instead of submitting the order is your condition set to instead set a bool variable to true. In another set you would check the market position to see if it is flat and if the bool variable is true, to then place the entry order. In another set you would need to check for a not flat position (meaning you were now in a position meaning the entry order filled) and you would set the bool back to false to prevent further orders. You would need yet another set to also set the bool false if the entry conditions are no longer valid. (You could also combine the last two sets by using the "if any" selection in a set.).

    Alternatively, you could save the entry level in a variable and in another set monitor price compared to that value and use a market order to enter when the price crosses the level. You would still use a bool variable set by your initial condition set to then allow another set to monitor price to the level and place the entry order when it is crossed.






    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thabks for your quick responce im am new to this but seems it would not be possible to do it while the code is still locked and has to be done edditing the code??

      Comment


        #4
        Hello cecilinvest,

        Thanks for your reply.

        Certainly the Strategy Builder provides some limitations compared to directly coding. The Managed Approach is also the default for Ninjascript coding as well, however you do have access to advanced order methods that would allow you to place limit orders that are not automatically canceled if not filled, however you would need to add logic to cancel the order.

        If you have not reviewed the Strategy Builder resources, here they are:
        Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
        Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
        Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm

        You may also benefit from looking at other Strategy Builder examples, while these do not directly relate to yours, they do show the use of variables and monitoring price: https://ninjatrader.com/support/foru...rategy-builder

        If you want to continue in the strategy builder, I would suggest working on a piece at a time until you have verified functionality, then create another strategy and work on a different piece again until you have it working and understood, then put the pieces together. To further assist, when trying to understand how something is working we recommend debugging. Debugging in the Strategy Builder can best be done by drawing objects on the chart when a "sets" conditions are true. Here is a short video on how to add markers and display them: https://paul-ninjatrader.tinytake.co...MF8xMTMwNTc0MA In addition sometimes you will want to understand what the value of various indicators/variables are and this can be done with the Print statement, here is a short video on how to debug with the Print statement in the strategy builder: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw

        An alternative is to have your well defined strategy created by a 3rd party NinjaTrader ecosystem vendor that provide custom programming services. If this is of interest we can provide a link to them.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,602 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 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
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X