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

buy order when stop price > current price

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

    buy order when stop price > current price

    I would like my strategy to send out a buy order such that when the price goes above a certain price, it places a market order to buy. For example, the current price is $100, and I want to send in a buy stop order where once the price reaches $105, I would like to send out a market order to buy.

    Is this done via:

    double stopPrice = 105;
    double limitPrice = 105;
    EnterLongStopLimit(limitPrice, stopPrice, "LongPosition");

    Thanks in advance,

    Ken

    #2
    I tried the equivalent short order, where the current price is > than the stop price and limit price (ie. current price is $105, and I want to short when the price hits $100).

    From what I can tell, my order to placed properly, but when the price moves through my stop price, instead of placing an order, I get the following error in the log:

    "A SellShort stop order placed at '11/2/2009 6:42:00AM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy."

    Is there anything I can do to solve this problem?

    Thanks in advance,

    Ken

    Comment


      #3
      If I follow you correctly, you should place a EnterLongStop order then, a buy stop market order - http://www.ninjatrader-support.com/H...rLongStop.html

      You could also just monitor for price fullfilling your condition (Close[0] > 105) and then sending just a market EnterLong().
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Here is a more detailed example (using the short trade)

        Using 1 min candles, the 6:40am bar (ie. all data >= 6:39am and < 6:40am) , the current bar is OHLC of 562.0/562.0/561.2/561.3.

        At this point, OnBarUpdate, I check to see if the close < 575. It is, therefore I issue the following:

        entryOrder = EnterShortStop(561, "ShortTrade");

        Which, from what I understand will trigger a short when the price reaches 561.

        I see the state of this order go from Pending, to Accepted, to Working, so I assume that this is okay.

        The next candle, the 6:41am candle, the price goes up. The OHLC is 561.4/562.5/561.4/561.7.

        However, I see that the order state goes to PendingCancel and then Cancelled. It seems to cancel it before we even get close to the stop order.

        Any clues as to what I'm doing wrong?

        Comment


          #5
          Suggest you run the order with liveUntilCancelled = true so it doesn't auto expire.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thank you! This was exactly the problem!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Lumbeezl, 01-11-2022, 06:50 PM
            31 responses
            817 views
            1 like
            Last Post NinjaTrader_Adrian  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            5 responses
            14 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by swestendorf, Today, 11:14 AM
            2 responses
            6 views
            0 likes
            Last Post NinjaTrader_Kimberly  
            Started by Mupulen, Today, 11:26 AM
            0 responses
            7 views
            0 likes
            Last Post Mupulen
            by Mupulen
             
            Started by Sparkyboy, Today, 10:57 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X