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

How to Place and Move a EnterShort()

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

    How to Place and Move a EnterShort()

    What I want to do is place a Short 1 tick Below the Low of the (Current Bar -1) , If the Short was not triggered somehow move the short to the next bar 1 tick below (Current Bar -1) until it's triggered.



    Here is the docs I am looking at.. Order Methods https://ninjatrader.com/support/help...er_methods.htm


    Code:
    
    if (Position.MarketPosition == MarketPosition.Flat) {
    //EnterShort(Convert.ToInt32(DefaultQuantity), "Short");
    //BuyShortLimit((Bars.GetLow(CurrentBar - 1) - (1 * TickSize)));
    
    
    }

    Any ideas how to place and move if needed?

    Thanks.

    #2
    Hello ntcat,

    Thanks for your post.

    Using EnterShort() the order would fill immediately as it is a market order.

    To place an order to go short at the previous bar low minus 1 tick, you would need to use https://ninjatrader.com/support/help...tstoplimit.htm

    If (Position.MarketPosition == MarketPosition.Flat)
    {
    EnterShortStopLimit(Low[1] - TickSize, Low[1] - TickSize);
    }


    In the managed approach, if the limit order is not filled on the bar it is submitted on, it will be automatically canceled. As your only entry condition is only checking for MarketPosition then it would continue to submit on each bar until filled, using the previous bars Low minus 1 tick.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      @NinjaTrader_PaulH

      It works well like I was expecting.. but my stops are a little rough..

      I am getting an error everytime... Sell stop or sell stop limit orders can't be placed above the market.. affected Order: SellShort 1 StopLimit @11449.25 X 11449.25

      I am using this trailing stop with default settings.

      This is a conversion of the NT7 misc ProfitTargetTrailingStop_101b Stop Strategy Framework Please contact the original author for any questions or comments. NT8‐ Added optional plot lines for Profit target and Stop. 7-8-2020 Changed the Calculate.OnBarClose to Calculate.OnPriceChange and relocated entry logic for best practice


      I think my options are to rewrite it to use EnterShortStopLimit OR EnterLongStopLimit instead of SetStopLoss

      OR

      How to do a market entry instead of EnterShortStopLimit.


      Any advise before I try to tackle this?

      Comment


        #4
        Hello ntcat,

        Thanks for your reply.

        I'm confused as you are switching between entry orders and setstoploss orders.

        The message is quite clear in that the Set stop (market) or Sell stop limit are being placed above the current market price, they must be submitted below the current price.

        If you are running the strategy with Calculate.OnBarClose then it is not looking at the current price before submitting the orders. Calculate.OnEachtick or Calculate.OnPriceChange will give you access to the current right edge price (Close[0]) that you can check before submitting orders to ensure the order are below the current price.



        Paul H.NinjaTrader Customer Service

        Comment


          #5
          @NinjaTrader_PaulH

          I figured out what I was doing......

          I am using OnTick and I calling the long or short over and over...

          Changed

          Code:
          [I]If (Position.MarketPosition == MarketPosition.Flat)
          {
          EnterLongStopLimit(High[1] + (1 * TickSize), High[1] + (1 * TickSize));
          }[/I]
          
          [B][/B]


          To


          Code:
          if (Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar == true) {
          EnterLongStopLimit(High[1] + (1 * TickSize), High[1] + (1 * TickSize));
          }
          
          [B][/B]




          It seems to be working well now...

          Comment


            #6
            I want to add an additional var in to the mix. I want to detect if the current trend is going in my direction, if not then I want to cancel any Long Setups only.... without canceling out the Short Setups.

            Code:
            if (Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar == true && curTrend == "UP") {
            EnterLongStopLimit(High[1] + (1 * TickSize), High[1] + (1 * TickSize));
            }
            One problem is when curTrend no longer equals "UP". How could I cancel any long. I am thinking we could use the Signal Name some how... am I on the right track?


            Code:
            if (Position.MarketPosition == MarketPosition.Flat && IsFirstTickOfBar == true && curTrend == "UP") {
            EnterLongStopLimit(High[1] + (1 * TickSize), High[1] + (1 * TickSize),"UPTREND LONG 1");
            }
            What I am not certain about is how to find a long trade that has not hit it's trigger target and cancel it. I don't want to accidentally cancel a short.

            Thanks in advance.

            Comment


              #7
              Hello ntcat,

              Thanks for your reply.

              Here is a link to an example of canceling an order: https://ninjatrader.com/support/help...thod_to_ca.htm

              Your forum topic is titled, "How to Place and Move a EnterShort()" which has been addressed. Your latest inquiry is a different subject. To help us keep the forum threads relevant, on a new subject, going forward, please create a new topic as this will help everyone that may be looking for your latest question. Thanks for your understanding.

              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Thank you.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                6 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Started by alifarahani, Today, 09:40 AM
                6 responses
                41 views
                0 likes
                Last Post alifarahani  
                Working...
                X