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

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 algospoke, 04-17-2024, 06:40 PM
        3 responses
        26 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bmartz, 03-12-2024, 06:12 AM
        3 responses
        29 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        2 responses
        9 views
        0 likes
        Last Post Aviram Y  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X