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 sofortune, Today, 02:31 AM
        0 responses
        7 views
        0 likes
        Last Post sofortune  
        Started by sofortune, Today, 01:55 AM
        1 response
        5 views
        0 likes
        Last Post sofortune  
        Started by cls71, Today, 01:37 AM
        0 responses
        8 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by WHICKED, 06-27-2023, 12:07 PM
        63 responses
        764 views
        1 like
        Last Post Leeroy_Jenkins  
        Started by rtwave, Today, 12:10 AM
        0 responses
        6 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X