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

Order entry methods?

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

    Order entry methods?

    Hello,

    I'm wanting to issue discrete:
    - Order Long Limit
    - Order Stop Loss
    - Order Profit Target.

    Is there a way to do that?

    Managed is preferred, though it has its problems.

    Unmanaged is fine if that provides the granularity of order submission I need.

    What I'm trying to do is:
    1. Wait for a signal
    2. If not in market, then issue an entry order
    3. If in market already, then reverse position:
    3.1 Close market position
    3.2 Issue an entry order.

    Seems simple enough, but I'm confused about which method to use and downsides.

    Many Thanks, Caesar.

    #2
    Hello Skechers,

    Thanks for your post.

    I understand that you would like to have individually separate and distinct orders placed by the strategy. For example, if you are not in a current position then place a long entry order with a stop loss and profit target. If you have a current position, reverse the position, stop loss, and profit target.

    In your order entry condition, you could check if Position.MarketPosition == MarketPosition.Flat to see if you are in a flat position and then call your Entry order method, such as EnterLong(). That way, the order is only submitted when you are in a flat position.

    You could create a condition that checks if Position.MarketPosition == MarketPosition.Long/Short to see if you are in a Long or Short position. Then, you could call your entry order in the opposite direction to reverse the trade. For example, if you are 1 Long, you could check if Position.MarketPosition == MarketPosition.Long and call EnterShort() to reverse the position.

    Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm

    From the Managed Approach help guide: Entry() methods will reverse the position automatically. For example if you are in a 1 contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position.

    Managed Approach: https://ninjatrader.com/support/help...d_approach.htm

    Set methods (SetStopLoss()/SetProfitTarget()) or Exit methods (ExitLongLimit()/ExitLongStopLimit()) could be used for your Stop Loss and Profit Target orders. See the available Set methods and Exit methods in the Managed Approach help guide linked above.

    Note that you cannot use both Set methods AND Exit methods in the same strategy as this violates the Managed Approach Internal Order Handling Rules linked below.
    https://ninjatrader.com/support/help...antedPositions

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hello Brandong,

      Many Thanks for that.

      So I would (for long positions)
      1. Exit Short Stop Market for the stop loss
      2. Enter Long Limit for the entry
      3. Exit Short Limit for the profit target
      They all return order objects. What states should then be normally in?

      If the profit target order is filled (#3), on OnOrderUpdate, how do I close the stop loss (#1)?

      Thanks, Caesar.

      Comment


        #4
        Hello Skechers,

        Thanks for your note.

        Please see this help guide page for information about order states: https://ninjatrader.com/support/help...efinitions.htm

        If you are in a long position, you could check if Position.MarketPosition == MarketPosition.Short and call your short exit order method.

        Then, you could check if Position.MarketPosition == MarketPosition.Flat in your long entry order condition and call your long entry order method.

        You could check if Position.MarketPosition == MarketPosition.Long and call your long exit order method.

        And, you could check if Position.MarketPosition == MarketPosition.Flat in your short entry order condition and call your short entry order method

        For information about using OnOrderUpdate and OnExecutionUpdate() see this reference sample: https://ninjatrader.com/support/help...and_onexec.htm

        Let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        4 responses
        10 views
        0 likes
        Last Post arvidvanstaey  
        Started by samish18, 04-17-2024, 08:57 AM
        16 responses
        56 views
        0 likes
        Last Post samish18  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        8 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X