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

EnterStopLimit usage

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

    EnterStopLimit usage

    Hello.
    I have a couple questions about EnterLongStopLimit and EnterShortStopLimit usage. Let's start with 1st one since the other ones depend on you response.

    Here is code #1​
    Code:
    if (Close[0].ApproxCompare(limitPrice) < 0)
    {
        EnterLongStopMarket(limitPrice);
    }
    else if (Close[0].ApproxCompare(limitPrice) > 0)
    {
        EnterLongLimit(limitPrice);
    }​
    Here is code #2​
    Code:
    EnterLongStopLimit(limitPrice, limitPrice);
    Here is the question #1. Is Code #1 the same as Code #2?
    Thank you.​

    #2
    Hello PopovDS,

    Thank you for your post.

    There would not be the same code as #1 has two separate entry order methods that are submitted conditionally and #2 is only using one order entry method to that specifies a limit and stop price in the same order.

    EnterLongStopLimit() generates a buy stop limit order to enter a long position.



    EnterLongStopMarket() generates a buy stop market order to enter a long position.



    EnterLongLimit() generates a buy limit order to enter a long position.



    Please let me know if you have any further questions.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response. Here is the question #2. I have the following sequence in my strategy:
      1. Once entry condition is met the logic goes long with EnterLongStopLimit.
      2. Once limit price is hit the limit order is filled.
      3. The logic waits for exit condition or entry condition of opposite direction (short).
      4. Short condition occurs earlier that exit one. The logic apply EnterShortStopLimit.
      5. It is expected that once limit price is hit the existing long position will be closed and short position will be created. But nothing happens because EnterShortStopLimit returns null.

      The interesting thing that when I place market short order it closes the long position correctly and creates new short position. Is there a way to re-open the opposite position by limit order?

      Comment


        #4
        Hello PopovDS,

        Thank you for your response.

        Are you calling an Exit order and an Entry order on in the opposite direction at the same time?

        Can you provide an example of how you are calling your entry and exit methods?

        An order with the name 'Close position' is automatically sent by NinjaTrader when calling an entry order in the opposite direction of the position. If you are trying to reverse the position, call the entry in the opposite direction without calling an exit order.

        This forum post also explains in detail:

        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Hello Gaby. Yes, I try to reverse the position. I don't use exit methods. The only thing I use limit orders EnterLongLimit or EnterShortLimit to reverse the position. This way those functions returns null... When using market orders such as EntryLong, EntryShort then it works.

          Comment


            #6
            Hello PopovDS,

            Thank you for your response.

            Can you provide a reduced script showing how you are calling the entry methods?

            Below I am attaching a simple sample script demonstrating using EnterLongLimit() and EnterShortLimit() to reverse positions.

            Please let me know if I can assist further.
            Attached Files
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              I think my issue is that I try to reverse the position, but there is stop loss has been already set... This way opposite limit order will be ignored, won't it?

              Comment


                #8
                Hello PopovDS,

                Are you using SetStopLoss()? Per the Internal Order Handling Rules, yes the order order submitted in the opposite direction will be ignored.

                From the Help Guide:

                "Methods that generate orders to enter a position will be ignored if:
                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"

                HTML Code:
                https://ninjatrader.com/support/helpGuides/nt8/index.html?managed_approach.htm#InternalOrderHandlingRulesThatReduceUnwantedPositions
                Please let me know if you have any further questions. ​
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  The strategy uses ExitLongLimit, ExitShortLimit, ExitLongStopMarket, ExitShortStopMarket to stop the trade. The logic of the strategy is complex enough. No way to predict the opposite entry condition is met. I need both stop orders and the possibility of the position to be reversed. Is there a possibility to get the desired result with using of Unmanaged Approach?

                  Comment


                    #10
                    Hello PopovDS,

                    Thank you for post.

                    Can you clarify - are you using Exit methods in your script? Earlier in another post you stated you were not using exit methods.

                    Yes, I try to reverse the position. I don't use exit methods.
                    What are you using for the stop loss? Are you submitting stop market orders like EnterLongStopMarket or ExitLongStopMarket, or are you using SetStopLoss as well?


                    The Unmanaged Approach will avoid having to follow the Internal Order Handling rules.



                    Below is a link to an example of bracket entry OCO orders using the unmanaged approach.


                    And a link to submitting OCO stop and target exits with the unmanaged approach.​
                    Gaby V.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by lightsun47, Today, 03:51 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post lightsun47  
                    Started by 00nevest, Today, 02:27 PM
                    1 response
                    8 views
                    0 likes
                    Last Post 00nevest  
                    Started by futtrader, 04-21-2024, 01:50 AM
                    4 responses
                    44 views
                    0 likes
                    Last Post futtrader  
                    Started by Option Whisperer, Today, 09:55 AM
                    1 response
                    13 views
                    0 likes
                    Last Post bltdavid  
                    Started by port119, Today, 02:43 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post port119
                    by port119
                     
                    Working...
                    X