Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy and sell stop order simultaneously

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

    Buy and sell stop order simultaneously

    Hi. I would like to create break out strategy, which find High and Low for specific time range and put buy stop order to High and put sell stop order to Low in one time and will wait for breakout, but ninja trader doesn't work if I use this code:
    EnterLongStop(High);
    EnterShortStop(Low);

    Could you help me?
    Thank you

    #2
    Hi Hanysfx,

    Thank you for posting.

    While your syntax is currently correct, you would need to index the High and Low in order for the system to understand the full placement of where to place the Stop orders.

    I.E.
    Code:
    EnterLongStop(High[COLOR="Red"][0][/COLOR]);
    EnterLongStop(Low[COLOR="Red"][0][/COLOR]);
    This references which bar value you would like the orders to be placed.

    You can also you the LowestBar and HighestBar to find the highest bar for so many bars ago and the lowest.
    http://www.ninjatrader.com/support/h...highestbar.htm
    http://www.ninjatrader.com/support/h...?lowestbar.htm

    I would also recommend to check the Log Tab of the Control Center for any possible errors from the NinjaScript.

    Additionally, you can use the TraceOrders = true; to check the orders and if any get ignored and why.
    http://www.ninjatrader.com/support/h...raceorders.htm

    Please let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by hanysfx View Post
      Hi. I would like to create break out strategy, which find High and Low for specific time range and put buy stop order to High and put sell stop order to Low in one time and will wait for breakout, but ninja trader doesn't work if I use this code:
      EnterLongStop(High);
      EnterShortStop(Low);

      Could you help me?
      Thank you
      Look in the Reference Samples forum ref: http://www.ninjatrader.com/support/f...splay.php?f=30, on this board, and you will find an exact example of what you are trying to do. Modify it for your needs.

      Comment


        #4
        answer

        High and Low are just variables(I have another name for this variables in code). Problem is, that Ninja trader maybe dont accept 2 stop order simultaneously. How can I solve this problem?

        Comment


          #5
          Hello hanysfx,

          Submitting limit orders in both directions can only be done with an unmanaged script. Using the managed approach you will not be able to achieve this.

          Below is a link to the help guide on SubmitOrder within the unmanaged approach. Please take a look at the OCOID.
          http://www.ninjatrader.com/support/h...ubmitorder.htm

          Also, below is a link to a strategy that is unmanaged and uses OCO.
          http://www.ninjatrader.com/support/f...atid=5&lpage=1
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          88 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          30 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          34 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          68 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X