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

Weird orders I didn't place.

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

    Weird orders I didn't place.

    I wrote a simple strategy with StopLoss and ProfitTarget. But when I run it in the chart, I found out it sometimes close my position prematurely with a Close position which I absolutely didn't put in my code!!!

    Could somebody PLEASE tell me what's going on and how to fix it please!? Thank you very VERY much! God bless you!!!

    #2
    Hello YoutingChu,

    Thanks for your post.

    Please review your close position exit times, do these occur at the close of the session?

    If not, please post a screenshot that shows the exits on the chart along with a screenshot of your entry coding.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Dear Paul,

      Thank you very very much for you help!
      Below is the screen shot of the order and my source code.
      The strategy is the basic Forex strategy, where you place an OCO order at the opening of the market and set ProfitTarget and StopLoss accordingly. But it close my order prematurely with a Close position which I had circled.
      Please tell me why did that happen and how do I fix it. Thank you very VERY much! God bless you!!!

      Snap Shot
      Source Code
      Last edited by YoutingChu; 07-30-2018, 06:56 AM.

      Comment


        #4
        Hello YoutingChu,

        Thanks for your reply.

        It looks like you are using EnterLong or EnterShort to place orders. These order methods will detect any open positions and will issue closing orders. For example, if the strategy was long one contract and the strategy issues one short order, EnterShort() would issue one sell to "close position" then enter a second sell to leave your strategy in the desired direction (in this case short 1).

        If you do not want this to happen then in your order entry block you may want to test to see if you are not flat, for example:

        if (Position.MarketPosition != MarketPosition.Flat)

        {
        // if not flat do something here
        }
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        21 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X