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

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:



    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, 09: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 sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,262 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by WeyldFalcon, 12-10-2020, 06:48 PM
        14 responses
        1,429 views
        0 likes
        Last Post Handclap0241  
        Started by DJ888, 04-16-2024, 06:09 PM
        2 responses
        9 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        41 views
        0 likes
        Last Post jeronymite  
        Working...
        X