Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I prevent a strategy from auto disabling after position is closed?

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

    How can I prevent a strategy from auto disabling after position is closed?

    I have created a new strategy and specified AUDUSD as the instrument. The strategy currently closes any open positions that are opened by a human. If I manually open a position on EURUSD, the strategy works fine and closes the position while leaving the strategy enabled. If I then manually open a position on AUDUSD, the instrument the strategy is attached to, the strategy closes the position and then automatically disables itself. In the code I am using the position.Close() method. I would like for the strategy to never automatically disable itself. How can I prevent this? Thank you.

    The log shows a category="Default "and Message="Disabling NinjaScript strategy 'MyStrategy/205101387'

    Right now, the only workaround I can think of is to create a new strategy and specify a different instrument such as "NZDUSD" and then I should be able to close EURUSD & AUDUSD positions without the strategy auto disabling itself. I am hoping there is a better way such as overriding what appears to be default behavior.
    Last edited by RFrosty; 07-03-2020, 01:35 PM.

    #2
    Hello RFrosty,

    Welcome to the NinjaTrader forums!

    A strategy will only become automatically disabled if an error occurs or if the connection is disconnected. Otherwise the strategy will keep running and will not be disabled.

    Are you certain that CloseStrategy() or setting the State is not in the code?

    Do you see any errors appearing on the Log tab of the Control Center when the strategy is disabled?

    Is the connection still connected?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I don't see any errors in the logs and I am not calling CloseStrategy anywhere.

      Comment


        #4
        I have attached the source to validate.
        Attached Files

        Comment


          #5
          Hello RFrosty,

          This strategy doesn't submit any orders. If there are no orders being submitted, I highly doubt this strategy is becoming disabled automatically.

          I ran this myself and it didn't disable. I'll leave it running in real-time for a while, but I highly doubt this strategy will disable as there are no orders being placed.
          https://drive.google.com/file/d/1_-B...w?usp=drivesdk

          Personally, I think what you provided is not the same script you are testing.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            I am manually opening an EURUSD and AUDUSD positions while the strategy is enabled. When I manually open the EURUSD, the Strategy closes the position which is expected. When I manually open the AUDUSD (the instrument the strategy is attached), the position is closed by the strategy as expected but the strategy is then auto disabled. I am expecting the strategy to remain enabled even if all positions are made flat by the strategy.
            Last edited by RFrosty; 07-05-2020, 08:18 PM.

            Comment


              #7
              Hello RFrosty,

              Manual orders are not able to be seen by NinjaScript Strategies.

              Manually clicking the Close button specifically will disable a strategy on the same instrument and account, so don't do this.
              If you want to manually close a position, place an order in the opposite direction and don't click Close.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Renorail, Today, 01:05 AM
              0 responses
              9 views
              0 likes
              Last Post Renorail  
              Started by NeverDownMoney, Yesterday, 08:06 PM
              1 response
              10 views
              0 likes
              Last Post NeverDownMoney  
              Started by GauthamK, Yesterday, 07:38 PM
              0 responses
              14 views
              0 likes
              Last Post GauthamK  
              Started by Czarek, Yesterday, 05:42 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by Hyper, Yesterday, 05:13 PM
              0 responses
              5 views
              0 likes
              Last Post Hyper
              by Hyper
               
              Working...
              X