Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

does not close the position

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

    does not close the position

    Good morning,
    I wrote the code with an Exit this way:

    if (Position.MarketPosition == MarketPosition.Short)
    {
    if (Low [0] <MIN (14) [1])
    {
    ExitShortStop (High [0], "ExitShortProva1", "ShortProva1");
    }
    }

    in the output is written like this:
    06/13/2000 22:00:00 Entered internal PlaceOrder () method at 13/06/2000 22:00:00:
    BarsInProgress = 0 Action = Stop = BuyToCover OrderType LimitPrice Quantity = 0 = 0 = 49.69 StopPrice SignalName = 'ExitShortProva1' FromEntrySignal = 'ShortProva1'

    The next day the stock open at 49.75 - 49.06 Low - High 51 .
    Why do not you close the position as written in the output to 49.69 ?

    Thank you.
    Hello.
    Roberto

    #2
    Hello Roberto,

    Few things that I see here.

    1. You are using a Stop order so the it must hit that price before the order will go executed. So depending on the Session template that you are using it may vary. What session template and instrument are you using?

    http://www.ninjatrader.com/support/h...on_manager.htm

    2. To keep your orders after the end of a session you want to have ExitOnClose set to false.
    http://www.ninjatrader.com/support/h...xitonclose.htm

    3. Note that when writing NinjaScript code the, CalculateOnBarClose(COBC) can vastly effect how your code functions. Which means that if CalculateOnBarClose is true, then the strategy/indicator will be calculated at the close of each bar. If your strategy is set to COBC=false, then it will act differently since it will be calculated on each tick. See the following link for more info on COBC.
    http://www.ninjatrader.com/support/h...onbarclose.htm

    4. How are you testing your strategy?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Attn: JC

      Good morning,
      I have attached a code toy. The problem is that the condition occurs, but the exit is not the case.
      Why?
      Use only U.S. stocks (Dow-Nasdaq-S & p500).

      Thank you.
      Roberto
      Attached Files

      Comment


        #4
        Hello Roberto,

        Thanks for that Toy script.

        I can confirm that your strategy will exiting a position.

        With that said, after looking at your code I believe what is happening is that your order for ExitLongStop()/ExitShortStop() is not being filled yet with the condition still becoming true, thus overriding your Exit order again with a new price.

        Can you try to use an exit order like: ExitLong("LongToy");


        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        337 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X