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

EnterShortStopLimit

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

    EnterShortStopLimit

    Hi, need help with my entry/stop logic. Here’s what I want to do: execute a short trade at a certain price level below the current bid price. To do this, my strategy executes an EnterShortStopLimit at that lower price level while the current price is still above it. (fyi, I use the long form of that method as I need to set isLiveUntilCancelled to true so the order doesn’t cancel at the end of the bar.) I also set the EnterShortStopLimit stopPrice at 5 ticks above the EnterShortStopLimit limitPrice.

    As soon as the current price moves to the EnterShortStopLimit limitPrice and my strategy enters a short position, I then want to reset my EnterShortStopLimit stopPrice value based on some other variables I’m calculating. To do this, I then execute a SetStopLoss for that new stop price. This is where I consistently get the message “Stop price can’t be changed below the market”.

    I’ve looked at some example strategies to see where I’m going wrong but couldn’t find anything. I’m sure my use of the above commands, or where they are placed is flawed. Any insight you can provide is greatly appreciated! Thanks

    #2
    Hello pman777,

    Thanks for your post.

    We recommend debugging your strategy by printing the variables that are "based on some other variables I’m calculating" to ensure that an appropriate price is being used for the SetStopLoss(). Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

    Can you clarify if this is correct, "I also set the EnterShortStopLimit stopPrice at 5 ticks above the EnterShortStopLimit limitPrice." I'm not sure why you would do that because then the order would be placed above the current price. Did you mean ExitShortStopLimit?
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Paul for replying so quickly. I did debug and the value is what I expected.
      Let me explain my thinking when I said "I also set the EnterShortStopLimit stopPrice at 5 ticks above the EnterShortStopLimit limitPrice." I’m assuming that this the stopPrice once my order is executed and price falls thought the limitPrice to place me in a short position. I realize I may be thinking about this wrong. I’m not sure if I should be using an ExitShortStopLimit?

      Is there an example strategy you can direct me to that uses a Managed EnterShortStopLimit and ExitShortStopLimit where the stopPice for an active order is modified?

      Comment


        #4
        Hello pman777,

        Thanks for your reply.

        There would be no example code because using Exit methods with SetStopLoss would violate the Internal Order Handling Rules that Reduce Unwanted Positions. Reference: https://ninjatrader.com/support/help...d_approach.htm

        Regarding SetStopLoss(), you will need to set the price level before you enter the position because the SetStopLoss() retains the last price you used for the stop and then immediately applies the stop upon entry and that likely would be the issue.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Ignoring what I was doing (previous comments) is there a strategy example you can direct me to where either a SellStopLimit or a BuyStopLimit is being used (Managed approach). I don't think I'm understanding how to structure these entries ... an example may help. thanks again

          Comment


            #6
            Hello pman777,

            Thanks for your reply.

            I'm not aware of an example so I created a quick one using EnterLongStopLimit().
            Attached Files
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              thanks Paul ... that's a great start for me! Appreciate it.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              0 views
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              2 views
              0 likes
              Last Post usazencortex  
              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  
              Working...
              X