Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders types, execute a order at a higher price in Ninjascript

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

    Orders types, execute a order at a higher price in Ninjascript

    Hello Forum,

    I'm trying to implement a buy order at a higher price in ninjascript.

    Ok this should be the logic.
    Bar Close is the trigger bar and price is at $1.5005 and there i want to place an order that it's executed at a price of $1.5010
    TakeProfit is at $1.5020
    StopLoss is at $1.5000

    In the pic you can see the trigger bar marked with a green arrow.
    this should generated the order
    and buy at the gray line, stop loss at red, and take profit at green.

    The order should be good till chanceled or one cancels the other.

    This is on 15min timeframe but should be executed when price hits the levels.
    Click image for larger version  Name:	Buyorder.jpg Views:	0 Size:	75.3 KB ID:	1141245

    I know, it is for sure so easy but it seems my brain is not of it capable today.
    Thanks for the help
    Last edited by fernlicht; 02-11-2021, 03:46 AM.

    #2
    Hello fernlicht,

    Thanks for your post.

    To place a buy order above the current price you would need to use a buy stop order, either a buystoplimit or a buystopmarket, Here are links to the methods:



    For your stop and profit, you could use the set methods, SetStopLoss() and SetProfitTarget(), you would need to set these at the price needed before the entry occurs as these methods will retain the previous price used and are deployed immediately upon entry so setting them first is critical. Here are links to those:



    You may want to review the documentation here for further information about the various order types and other considerations: https://ninjatrader.com/support/help...d_approach.htm

    Comment


      #3
      Ok thx,
      but I tried the doumentation examples already, it only works for the same candle.
      As one might see in the picture the trigger and buystop order was 2-3 candles before and the order is no longer valid.

      Comment


        #4
        Hello fernlicht,

        Thanks for your reply.

        Most strategies will run under the "managed approach" (last link in post #2). From that documentation 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 need to resubmit the order on each new bar to keep it alive until filled.

        Alternatively, you can use the advance order handling overload that provides a bool isLiveUntilCancelled.

        Comment


          #5
          Hi Paul, thanks for your input. this quick and dirty solution was the kind of thing i was looking for .

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          38 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X