Announcement

Collapse
No announcement yet.

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.

      https://ninjatraderecosystem.com/use...lingstop_101b/

      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:
          If (Position.MarketPosition == MarketPosition.Flat)
          {
          EnterLongStopLimit(High[1] + (1 * TickSize), High[1] + (1 * TickSize));
          }


          To


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




          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 JuanPabloQuevedo, Yesterday, 05:27 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by StevenNelson, Yesterday, 03:24 PM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by my-trade, Yesterday, 10:45 AM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by s.kinra, Yesterday, 11:36 PM
                0 responses
                6 views
                0 likes
                Last Post s.kinra
                by s.kinra
                 
                Started by oz187, Yesterday, 11:31 PM
                0 responses
                7 views
                0 likes
                Last Post oz187
                by oz187
                 
                Working...
                X