• 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

  • 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 5element, Today, 02:46 PM
0 responses
2 views
0 likes
Last Post 5element  
Started by darkgreen, Today, 09:36 AM
1 response
5 views
0 likes
Last Post NinjaTrader_Kate  
Started by JuanPabloQuevedo, Today, 01:04 PM
1 response
6 views
0 likes
Last Post NinjaTrader_Tyler  
Started by augustfay, Today, 10:46 AM
1 response
18 views
0 likes
Last Post NinjaTrader_Kate  
Started by neilzep, Today, 11:16 AM
3 responses
20 views
0 likes
Last Post NinjaTrader_PaulH  
Working...
X