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

  • NinjaTrader_JC
    replied
    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.

    Leave a comment:


  • Italy
    replied
    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

    Leave a comment:


  • NinjaTrader_JC
    replied
    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.

    Leave a comment:


  • Italy
    started a topic does not close the position

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by GussJ, 03-04-2020, 03:11 PM
16 responses
3,281 views
0 likes
Last Post Leafcutter  
Started by WHICKED, Today, 12:45 PM
2 responses
19 views
0 likes
Last Post WHICKED
by WHICKED
 
Started by Tim-c, Today, 02:10 PM
1 response
9 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by Taddypole, Today, 02:47 PM
0 responses
5 views
0 likes
Last Post Taddypole  
Started by chbruno, 04-24-2024, 04:10 PM
4 responses
53 views
0 likes
Last Post chbruno
by chbruno
 
Working...
X