Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLongLimit() and EnterLongLimit() at the same time?

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

    EnterLongLimit() and EnterLongLimit() at the same time?

    I have a strategy that's working bug-free. It's entering an order as expected. I am hand-coding additional custom code off of a strategy-built base.

    The first order is a swing trade of 12 points. Again, this is working perfectly. I'd like to add an additional order 8 points above my first order. I'm simply wanting to scale in on the winners.

    sudo code is:

    if ( conditions are true)

    {

    EnterLong(convert.ToInt32(NumOfContracts), "ID1"); // this works!
    EnterLongLimit(GetCurrentBid(). "ID2"); // this does not fire off even though I have pulled this bit of code from a post on this forum.

    }

    On the Strategies panel, I have set the Order handling / Entries per direction to 10.

    A limit order seems to be the only order that accepts a price argument so I'm trying to use EnterLongLimit.

    I totally get that EnterLongLimit(GetCurrentBid(). "ID2") will not place the buy 8 points above, it should set it at the current market but I'll figure that out later. For now, I literally can't get two orders to fire off at the same time. One should enter the market right away and the second-order should sit, perched 8 points above my new order, waiting to fire off if the price catches up to it.

    https://ninjatrader.com/support/help...er_methods.htm (EnterLongLimit())

    I have read and reread these docs but they're not helping me figure out this issue. Also, the examples only show one version of the method while 5 are listed up top. I've tried a few example bits of code that I've searched for in this forum but again no luck.

    What am I doing wrong?

    Thanks!


    #2
    Hello coopgrafik,

    Thanks for your post.

    Whenever a strategy (or indicator) is not working as expected, always check the "Log" tab of the Ninjatrader control center as this will usually provide some error message.

    To enter a long position above the current price, you should use an EnterLongStopMarket() or EnterLongStopLimit() type order. An EnterLongLimit() order would need to be placed below the current price.

    References:
    https://ninjatrader.com/support/help...gstoplimit.htm
    https://ninjatrader.com/support/help...stopmarket.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I tried to swap one order line with another as a baby step. Let's just see if I can enter the market about 8 points above the current price.

      if ( conditions are true)

      {

      // EnterLong(convert.ToInt32(NumOfContracts), "ID1"); // this is the line of code that works.
      EnterLongStopMarket( (Close[0] + (TickSize*34) ), "Test Entry"); // this is the new line of code but it doesn't work

      }


      I see an error in the order log that states something like, "An Enter() method to submit an order has been ignored"

      I searched the docs for "internal order handling rules" but the search results don't exactly match that phrase. It's not clear what specifically I'm supposed to review. I'm trying to sort through https://ninjatrader.com/support/help...er_methods.htm but again all the example code seems so simple—literally one line. So again, I'm not sure what I'm missing.

      Thanks for the help

      Last edited by coopgrafik; 01-19-2021, 08:53 PM.

      Comment


        #4
        Hello coopgrafik,

        Thanks for your reply.

        The error message is advising an entry method has been ignored, therefor you would check the rules under "Methods that generate orders to enter a position will be ignored if:"

        These are the specific rules under that heading:

        Methods that generate orders to enter a position will be ignored if:

        •A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction

        •A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction

        •A position is open and two or more Entry methods to reverse the position are entered together. In this case the second Entry order will be ignored.

        •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

        •The entry signal name is not unique



        Which one of these rules would apply to your strategy at the moment of the error?

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fscabrera03, Today, 05:46 PM
        0 responses
        1 view
        0 likes
        Last Post fscabrera03  
        Started by jleira, Today, 05:45 PM
        0 responses
        1 view
        0 likes
        Last Post jleira
        by jleira
         
        Started by AaronKoRn, Today, 03:05 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Emily  
        Started by zacharydw00, Today, 02:21 PM
        2 responses
        15 views
        0 likes
        Last Post zacharydw00  
        Started by Harvard, Today, 12:01 PM
        2 responses
        15 views
        0 likes
        Last Post Harvard
        by Harvard
         
        Working...
        X