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

Can't cancel position by StopLoss

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

    Can't cancel position by StopLoss

    Hello.

    I make a strategy using Managed and Advanced Order Handling approach.
    Strategy have to work on UniRenko bars.
    UniRenko bars have "fake" open price, so I can't use ExitLong() and ExitShort(), since they close deal on Open price.

    In NT7 I used
    PHP Code:
    SetStopLoss"Signal Name"CalculationMode.PriceCloses[0][0], false ); 
    In NT8 It works on history too, but cause errors in real-time (please, look in attach).

    So, how to let SetStopLoss() work for me? It very clear and reliable. It don't need any additional efforts on order handling.

    And I didn't find any restrictions of using SetStopLoss() in way like this.

    Attached Files
    Last edited by fx.practic; 08-13-2017, 09:15 AM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    The error indicates that the order is rejected by the broker. The managed approach was not violated but the price of the order is either at or below the ask price on the buy side or at or above the bid price on the sell side.

    I would recommend that you place your stop loss a few ticks away from the current price instead of at the current price.

    Also, when using a price as the stop loss value (or other order value), be sure the check that the price is on the correct side of the market before placing the order.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So, there are no any other way to exit deal at price, nearest to current price, except market exit orders (ExitLong(), ExitShort()), right?
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        fx.practic,

        You could choose a price 1 tick above the ask or 1 tick below the bid with a stop order.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks, I understand logic.
          I tried, even, both:

          PHP Code:
          SetStopLossGetCurrentAsk() - TickSize );
          SetProfitTargetGetCurrentBid() + TickSize ); 
          But, I still have errors.

          NT8 superior-realistic sim-engine is suspected : StopOrder need time to be changed.
          On big replay speed it just have no time to be changed.
          Otherwise, on backtest stop losses works norm.
          So, may be ExitLongStopMarket(price) will help me.
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            Hello fx.practic,

            Are you setting the price of the stop loss after the entry order is placed or before it is placed?

            The stop loss will continue using the old price if it is not set and updated before a new order is placed.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Yes.
              ExitLongStopMarket() and ExitShortStopMarket() (resubmitted on each bar) solved the problem.

              So, not SetStopLoss( Close[0] ) for closing position generated problem, but regular stop loss, far from price on submitting before new position opens.

              And error appearance was depended from MarketReplay speed - so, it was difficult to locate.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Originally posted by fx.practic View Post
                Yes.
                ExitLongStopMarket() and ExitShortStopMarket() (resubmitted on each bar) solved the problem.

                So, not SetStopLoss( Close[0] ) for closing position generated problem, but regular stop loss, far from price on submitting before new position opens.

                And error appearance was depended from MarketReplay speed - so, it was difficult to locate.
                Right note, thank You, but I encountered this problem many times, so have instinct now: first SetStolLoss(), than EnterLong().
                fx.practic
                NinjaTrader Ecosystem Vendor - fx.practic

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by love2code2trade, Yesterday, 01:45 PM
                4 responses
                28 views
                0 likes
                Last Post love2code2trade  
                Started by funk10101, Today, 09:43 PM
                0 responses
                7 views
                0 likes
                Last Post funk10101  
                Started by pkefal, 04-11-2024, 07:39 AM
                11 responses
                37 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Yesterday, 08:51 AM
                8 responses
                44 views
                0 likes
                Last Post bill2023  
                Started by yertle, Today, 08:38 AM
                6 responses
                26 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Working...
                X