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

Strategy in simulation mode: immediately closes position

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

    Strategy in simulation mode: immediately closes position

    OK, I'm probably overlooking a setting somewhere...

    When I attach a strategy to a live chart (simulation mode), the position that was opened a few bars ago is immediately closed on the last bar of the chart when I attach the strategy, instead of acting like the strategy has been running the whole day, a position opened say one hour ago and keeping the position open. The position is not closed by the strategy itself, it is NT doing this for some reason.

    What setting am I overlooking?

    #2
    imported post

    Do you mean last bar of a session? The only way a strategy is closed outside of your code is if Exit on close is set to true when apply a strategy.

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      The last bar on the chart (not the end of a session).
      So at the moment I put the strategy on the chart the last position entered by the strategy is closed on the last bar of the chart, no matter what.

      I'm not using ExitOnClose in my strategy.

      I'm sure I'm overlooking something, since it didn't behave like this before... (with the same strategy)

      Comment


        #4
        imported post

        Is there a name on this order that closes the position? Would see it marked on the chart or in the orders tab of the Control Center.

        Ray
        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          It's just says 'Close position'
          I see nothing in the orders tab

          Comment


            #6
            imported post

            I checked our code and this "Close position" is named when a strategy executes an Enter() method when a position already exists.

            I suggest adding afew print statements before some of your Enter() methods and see what is being called when that position exits.

            Something like:

            Print("EnterLong() called at " + Time[0]);

            Ray
            RayNinjaTrader Customer Service

            Comment


              #7
              imported post

              I just discovered that if I select "wait until flat before executing live" instead of "immediately submit live working historical orders", then this closing order disappears.

              However, I still think my strategy is not generating this order. And if it did, wouldn't the order be always at the same place? Now it is always at the last bar of the chart at the moment that I place the strategy on it...

              Comment


                #8
                imported post

                100% that the strategy is generating the order. Since the order name cames from within the strategy class internal PlaceOrder() method which gets called from any Enter() or Exit() method.

                There is always a chance that maybe a bug on our end but I can't see it. Running the debug print statements as per my last post will clarify what is happening.

                Ray
                RayNinjaTrader Customer Service

                Comment


                  #9
                  imported post

                  Using the print statement as you suggested, I don't see any order at the moment that the 'close position' appears.
                  But I wasn't expecting that anyway because the time that the 'close position' statement appears does not depend on my strategy but on the moment that I put the strategy on the chart (like I wrote below).

                  Does my previous post give any clue?

                  Comment


                    #10
                    imported post

                    Unfortunately your previous postdoes not providea clue.

                    Please send me the following:

                    Image of the strategy dialogue window with the settings you have to reproduce the problem.
                    Your strategy
                    Bar interval you are running on.

                    ray at ninjatrader dot com


                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      imported post

                      The marketcondition has now changed such that a genuine position closing happened, so right now I cannot generatethe problem anymore.
                      So I need to waitfor a new live condition or make modifications in the strategy to make this situation happen again.

                      In the meantime I have discovered that at the same timethe Stoploss seems to get ignored, but only at the last part of the chart.Everywhere else there is no problem.
                      Maybe the problems are related.
                      I don't think there is anything wrong with a statement like:
                      SetStopLoss(LongEntrySignal, CalculationMode.Ticks, stoploss, false);

                      Anyway, I will keep monitoring this and when it happens again I'll send you the strategy and images that you asked for.

                      Comment


                        #12
                        imported post

                        Thanks.
                        RayNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        18 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        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
                        9 views
                        0 likes
                        Last Post Javierw.ok  
                        Started by timmbbo, Today, 08:59 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post bltdavid  
                        Working...
                        X