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

Close Non-Strategy Positions From Strategy

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

    Close Non-Strategy Positions From Strategy

    Hi

    I am working on an idea where I use different time frames throughout the day. Say 1 minute from 6:30-7:30 and then 5 minute from 7:30 to close.

    My thought is to have two different instances of the strategy with the appropriate time frame set.

    What I'm wondering is, say I am now in the 7:30 instance, but I have a long position still open from the 6:30 instance. Then my 7:30 instance generates a sell signal, will calling EnterShort reverse the position for me as it would if the current position had been opened from the same strategy?

    Or will it just open an additional position, and I wouldn't have any control over the existing position from my new instance of the strategy?

    #2
    Hello calebsandfort,

    Thanks for your post.

    If you are running two strategies on the same instrument and the same account your account position will likely not reflect the strategy position. In your example of being 1 long on the first strategy, when the 2nd strategy goes short, it will close the account position (you will be flat), however both strategies will continue running as if they were still long and still short and will continue placing live orders based on their "strategy" position.

    Strategies run without regard to any other strategy and are not aware of each other. There are two solutions, one would be to open a second account and assign each strategy to a different account as this will prevent one affecting the other. Alternatively, combine the two strategies into one by adding a 5-minute data series and using a time filter in your code. By using a single instance your code can then determine the current position of the strategy/account and decide to or not to place an order.

    Note; If you decide to add the 5-minute data series you would be creating a multi-timeframe script and will require different considerations in methods and properties, I have linked a reference to multi-timeframe coding.

    References:


    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Aviram Y, Today, 05:29 AM
    0 responses
    2 views
    0 likes
    Last Post Aviram Y  
    Started by quantismo, 04-17-2024, 05:13 PM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    7 responses
    34 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cls71, Today, 04:45 AM
    0 responses
    6 views
    0 likes
    Last Post cls71
    by cls71
     
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    217 views
    1 like
    Last Post PaulMohn  
    Working...
    X