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

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

    Leave a comment:


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

    Leave a comment:


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

    Leave a comment:


  • RFrosty
    replied
    I have attached the source to validate.
    Attached Files

    Leave a comment:


  • RFrosty
    replied
    I don't see any errors in the logs and I am not calling CloseStrategy anywhere.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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?

    Leave a comment:


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

Latest Posts

Collapse

Topics Statistics Last Post
Started by Kediil, Today, 09:26 AM
0 responses
1 view
0 likes
Last Post Kediil
by Kediil
 
Started by bootize, Today, 08:37 AM
0 responses
6 views
0 likes
Last Post bootize
by bootize
 
Started by _Zero_, 01-06-2020, 01:16 PM
4 responses
138 views
2 likes
Last Post globaljobber  
Started by sukhob, Yesterday, 04:27 PM
2 responses
21 views
0 likes
Last Post sukhob
by sukhob
 
Started by zacharydw00, Yesterday, 05:36 PM
0 responses
6 views
0 likes
Last Post zacharydw00  
Working...
X