• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Sh00tHerMcGavin, Yesterday, 07:39 PM
        0 responses
        3 views
        0 likes
        Last Post Sh00tHerMcGavin  
        Started by Mberg, Yesterday, 05:13 PM
        0 responses
        1 view
        0 likes
        Last Post Mberg
        by Mberg
         
        Started by Barry Milan, Yesterday, 01:33 PM
        2 responses
        10 views
        0 likes
        Last Post marcus2300  
        Started by NW Trader, Yesterday, 03:42 PM
        2 responses
        8 views
        0 likes
        Last Post NW Trader  
        Started by ralett, Yesterday, 01:42 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X