Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position doesn't open

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

    Position doesn't open

    Hello,

    I created a strategu based on insidebar and violating its low or high. Deponds on direction of market.

    There is no problem w long transaction, but short transactions aren't opened by strategy. Why? A think that conditions and actions are correctly.

    This is the code.

    protected override void Initialize()
    {
    SetStopLoss("dluga", CalculationMode.Ticks, 36, false);
    SetProfitTarget("dluga", CalculationMode.Ticks, 72);
    SetStopLoss("krotka", CalculationMode.Ticks, 36, false);
    SetProfitTarget("krotka", CalculationMode.Ticks, 72);

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (High[0] < High[1]
    && Low[0] > Low[1])
    {
    DrawDot("My dot" + CurrentBar, false, 0, High[1] + 1 * TickSize, Color.Blue);
    }

    // Condition set 2
    if (High[0] < High[1]
    && Low[0] > Low[1])
    {
    EnterLongStop(DefaultQuantity, High[0] + 1 * TickSize, "dluga");
    }

    // Condition set 3
    if (High[0] < High[1]
    && Low[0] > Low[1])
    {
    EnterShortStop(DefaultQuantity, Low[0] + -1 * TickSize, "krotka");


    Please help.

    #2
    Hello Danielj,

    TraceOrders is useful for debugging strategy order submission issues. Add this line to your initialize() method:
    TraceOrders = true;

    You'll then see output by clicking Tools > output window.

    With this strategy, you'll likely see messages about ignoring positions due to internal order handling rules. You're conditions for short and long entry are the same, so one of these orders is ignored.

    Methods that generate orders to enter a position will be ignored if:
    A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
    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
    The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
    The entry signal name is not unique
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks but in output window there is nothing. This is the code:

      protected override void Initialize()
      {
      SetStopLoss("dluga", CalculationMode.Ticks, 36, false);
      SetProfitTarget("dluga", CalculationMode.Ticks, 72);
      SetStopLoss("krotka", CalculationMode.Ticks, 36, false);
      SetProfitTarget("krotka", CalculationMode.Ticks, 72);

      CalculateOnBarClose = true;

      TraceOrders = true;

      }

      I am using NT version 6.5.

      Comment


        #4
        Please make sure you have compiled and also reapply any instances of the strategy. You will want to open the output window before starting the strategy.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I didin't compile this. Now it's working. Thank you.

          But I have another question. Is there possibility of creating strategy (which about I wrote before) which both place buy stop orders on the high of insidebar and sell stop orders on the low of insidebars. Or do you recomend creating two seperate strategies: one for long, and another for short?

          If there is a possibility of putting all coditions in one strategy please give me a tips or place where I can find the tips.

          Thank you
          Daniel

          Comment


            #6
            The problem with using two strategies is there is no communication between them. You wouldn't be able to cancel the unfilled stop order on the other strategy.

            In order to submit both of these orders you would have to move to an unmanaged strategy. This is new for version 7. You can see an introduction to unamanaged order system here:
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              SetStopLoss Cost in Percent Profitablity

              Why does the SetStopLoss, even when I set it to stop out at 1 tick cost me 20 to 30 percent profitability. I just realized I've been battling trying to get the profitability up and all I had to do is disable this and recompile and it's up 20 to 30 percent.

              //SetStopLoss("", CalculationMode.Ticks,1,false);

              I'm using Backtest101 data.

              Comment


                #8
                This is likely simply to close Bill, so you're getting stopped out immediately for very small movement against your position.

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  The problem with using two strategies is there is no communication between them. You wouldn't be able to cancel the unfilled stop order on the other strategy.

                  In order to submit both of these orders you would have to move to an unmanaged strategy. This is new for version 7. You can see an introduction to unamanaged order system here:
                  http://www.ninjatrader.com/support/h...d_approach.htm
                  Hi,

                  For those of us still on 6.5 is it possible to achieve what the original poster wanted?

                  I have the same issue...

                  I want to create a BuyStop above a range and a SellStop below, the problem is that depending on the sequence I create them, only the first to be created appears to have been accepted.

                  Running TraceOrders shows both orders have been submitted but only the first one created is cancelled (if not executed first) at the end of the daily session suggesting the other one has been ignored. My order entry code is simply...

                  EnterLongStop(0, true, 0, High[HighestBar(High, 39)], "EnterLong");
                  EnterShortStop(0, true, 0, Low[LowestBar(Low, 39)], "EnterShort");

                  ... the condition to enter is the same for both but it is unlikley for both orders ever to be filled in the same session.

                  The log also shows one order has been ignored, there should be hundreds but I assume that only the first is recorded in the log?

                  As these are both working orders at the point of submission rather than executed is it not possible to have them both working at the same time? Is there another tack that I can take with this issue?

                  Thanks in advance for your help - I'll continue to trawl the forums!!

                  Oz

                  Comment


                    #10
                    Hello Oz,

                    With 6.5 you won't be able to submit both buy stop and sell stop orders at the same time.

                    One work around here is submitting market orders that are sent conditionally when price reaches the level you would have used for your stop order.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Ryan,

                      Thanks for the rapid reply, sounds like a reasonable workaround!

                      Oz

                      Comment


                        #12
                        Strategy Analyzer

                        I ran DanielJ's strategy and it hung the system. I had to turn strategy analyzer off. I believe there are no buy's or sell's in the strat, so there is nothing going on. How
                        can you set stops on orders that don't exist.If you don't have a market position which
                        means you're flat, you cannot have a stop. It's an impossibility. You cannot have a
                        stop on a non existant market position. Put some buys and sellls in there. And then
                        run it against the strategy analyzer with backtest101 data.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        633 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        364 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        105 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        567 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        568 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X