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

Enter OCO Order?

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

    Enter OCO Order?

    Hi

    Using managed orders can I do something like:

    Code:
    EnterLongLimit(1, ask - (2  * TickSize), "ENTER");
    EnterLongStopMarket(1, ask + (2  * TickSize), "ENTER");
    and have it basically act as an OCO order? I'm doing something similar with exit orders and seem to be getting the expected OCO behavior. But with the enter orders it only seems to be respecting the first order.

    Do I have to use unmanaged orders?

    Any help would be appreciated.

    #2
    Hello calebsandfort,

    Thanks for your post and welcome to the NinjaTrader forums!

    In the Managed Approach, under the "Internal Order Handling Rules that Reduce Unwanted Positions", under the "Methods that generate orders to enter a position will be ignored if:" there is this applicable rule: The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction Reference link: https://ninjatrader.com/support/help...d_approach.htm

    Staying with the managed approach, you could replace the limit orders with code that checks the price against the two entry levels and then when price hits either level place a market order to fill immediately. You would want to run this part of your code in the calculate mode of OnEachTick.

    For example:

    if (your conditions to enter )
    {
    double limitPrice = ask - (2 * TickSize);
    double stoplimitPrice = ask + (2 * TickSize)

    if (Close[0] <= limitPrice || Close[0] >= stoplimitPrice)
    {
    EnterLong();
    }
    }

    Notes: When using Calculate.OnEachTick, Close[0] = current price. You would need additional logic to control the flow to limit to one entry.

    Alternatively, you could use the Unmanaged approach which does not restrict orders.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cls71, Today, 04:45 AM
    0 responses
    1 view
    0 likes
    Last Post cls71
    by cls71
     
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    213 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    544 views
    0 likes
    Last Post PaulMohn  
    Started by GLFX005, Today, 03:23 AM
    0 responses
    3 views
    0 likes
    Last Post GLFX005
    by GLFX005
     
    Started by XXtrader, Yesterday, 11:30 PM
    2 responses
    12 views
    0 likes
    Last Post XXtrader  
    Working...
    X