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() Method Problem

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

    Enter() Method Problem

    Is it possible to have 2 orders working at the same time with NT?
    I am trying to submit two EnterStopLimitOrders simultaneously one to buy above the market and one to sell below when certain conditions are met. I also want the orders to be cancelled within a couple of bars if orders are not executed, or when one of the orders is executed.
    The problem when I run this, is only one order is submitted not 2, in the Log I get a message ‘An Enter() method to submit an order has been ignored’

    Any idea where I am going wrong?

    Thanks


    private IOrder myEntryOrder1 = null;
    private IOrder myEntryOrder2 = null;
    privateint barNumberOfOrder = 0;
    if # my conditions #
    && myEntryOrder1 == null
    && myEntryOrder2 == null)
    {
    myEntryOrder1 = EnterLongStopLimit(0, true, 1, 3, 1, "Buy");
    myEntryOrder2 = EnterShortStopLimit(0, true, 1, -3, -1, "Sell");
    barNumberOfOrder = CurrentBar;
    }
    Last edited by John833; 11-19-2008, 12:15 PM.

    #2
    Hello,


    In NinjaScript you cannot have two orders open at the same time in opposite directions.

    You will need to create a criteria to enter long and short depending on where price has moved to etc.

    This link will help:
    DenNinjaTrader Customer Service

    Comment


      #3
      Hi Ben, thank you for your reply, however buy and sell EnterStopLimit orders are independent of each other.

      Logically I would have thought a buy and sell StopLimitOrder could exist at the same time without conflict?

      Are you sure there is no way round this?

      Comment


        #4
        Hello,

        The only way around it is to have two strategies running seperately. However the strategies can't communicate with each other.

        EnterLongStopLimit() and EnterShortStopLimit() are not allowed to work simultaneously because of the implications. Remember, in NinjaTrader Enter methods come with a "Close position" order if you already have a position in the opposite direction. Let us say your EnterLong partial filled and then your EnterShort started to part fill also. What happens for the "Close position" order that would trigger with the EnterShort now? Your final order position becomes unpredictable.
        DenNinjaTrader Customer Service

        Comment


          #5
          Yes I see the issue, thanks for the explanation

          Regards John

          Comment


            #6
            Woulnd't it help to have to orders: CloseAllShortPositions and CloseAllLongPosition?

            Comment


              #7
              Hello,

              It would help to close all of the Long or Short working orders, so they do not conflict as mentioned. However you may want to use ExitLongLimit(), ExitLongStop(), or ExitLongStopLimit() for example:


              DenNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jackiegils, Today, 11:05 PM
              0 responses
              5 views
              0 likes
              Last Post jackiegils  
              Started by cre8able, Yesterday, 09:15 PM
              2 responses
              17 views
              0 likes
              Last Post cre8able  
              Started by Trader146, Today, 09:17 PM
              0 responses
              9 views
              0 likes
              Last Post Trader146  
              Started by ttrader23, 05-08-2024, 09:04 AM
              9 responses
              43 views
              0 likes
              Last Post ttrader23  
              Started by ZeroKuhl, Yesterday, 04:31 PM
              8 responses
              46 views
              0 likes
              Last Post ZeroKuhl  
              Working...
              X