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

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
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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 Aviram Y, Today, 05:29 AM
          0 responses
          1 view
          0 likes
          Last Post Aviram Y  
          Started by quantismo, 04-17-2024, 05:13 PM
          3 responses
          25 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          7 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cls71, Today, 04:45 AM
          0 responses
          6 views
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          216 views
          1 like
          Last Post PaulMohn  
          Working...
          X