Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place buy and sell Order

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

    Place buy and sell Order

    I have been trying to place a buy and a sell order just before market opens.

    The 2 issues are the following:

    Only a long or a short will be placed but not both.

    The second issue is when the market opens my order disappears

    I thought I found the issue about managed vs unmanaged but when I set unmanaged to true, my strategy goes to false. Here is the tidbit of code.



    if(currentHour == 7 && ( currentMinute == 29))
    {
    // Unmanaged = true; THIS DOESN'T WORK IT TURNS OFF MY STRATEGY.

    EnterShortStop(openLowBarPrice); THIS WILL TRIGGER
    EnterLongStop(openHighBarPrice); THIS WILL NOT TRIGGER

    Print("The low price is " +openLowBarPrice);

    //SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 1,openHighBarPrice);//, 0, "OCO", "LONG"); THIS WILL NOT TRIGGER

    //SubmitOrder(0, OrderAction.Sell, OrderType.Stop, 1, openLowBarPrice);//, 0, "OCO", "SHORT"); THIS WILL NOT TRIGGER

    }


    THE CODE IS PLACED IN OnBarUpdate()

    #2
    Hello ballboy11,

    I have noticed your comment that the Unmanaged = true; is causing the strategy to become disabled. This is likely because in the code EnterShortStop is being used.

    When using the unmanaged approach you must use SubmitOrder for submitting all orders entry and exit. Using Enter / Exit methods will work in the managed approach and will not work in the unmanaged approach.

    Below is a link to the help guide on the unmanaged approach. Please see the section 'Working with Unmanaged order methods' for sample code that demonstrates how to place orders with the unmanaged approach.
    http://ninjatrader.com/support/helpG...d_approach.htm


    It is required to use the unmanaged approach to place opposing orders in this manner. In the managed approach, calling EnterLongStop and EnterShortStop will violate the internal handling rules.

    The particular rule is:
    Methods that generate orders to enter a position will be ignored if:
    • 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
    Below is a link to the help guide on the managed approach. Please see the section 'Internal Order Handling Rules that Reduce Unwanted Positions'.
    http://ninjatrader.com/support/helpG...d_approach.htm

    Using the unmanaged approach, you can place a buy stop and a sell stop at the same time and you can also use OCO with these orders so that if one is filled the other is automatically cancelled.

    Attached is a working example I have created to demonstrate.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Could you provide this example for NT8?

      Comment


        #4
        Hello Lumbeezl,

        Please see the ProfitChaseStopTrailUnmanagedExample_NT8.zip found from the link below.

        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by MSerag, 05-06-2024, 11:52 PM
        6 responses
        33 views
        0 likes
        Last Post MSerag
        by MSerag
         
        Started by Critical_Catch, 05-19-2024, 08:35 AM
        2 responses
        28 views
        0 likes
        Last Post Ultrageuss  
        Started by Human#102, 05-20-2024, 05:18 AM
        4 responses
        24 views
        0 likes
        Last Post Human#102  
        Started by GreyKerns09, Yesterday, 03:42 PM
        2 responses
        20 views
        0 likes
        Last Post TradeSaber  
        Started by gacefitzgexald, Today, 02:59 AM
        0 responses
        5 views
        0 likes
        Last Post gacefitzgexald  
        Working...
        X