• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

disabling strategy after closed trade

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

    disabling strategy after closed trade

    I am building a strategy and would like for it to automatically 'disable' after a trade is closed.

    essentially, i would like to have it set up where i pick a stock, start the strategy on it (starting the strategy immediately opens a long or short), and then when the parameters are met to close the trade, the trade is closed and the strategy stops.

    I have achieved this thus far by having a bool flip on when i exit a long or short that prevents me from automatically entering another trade.

    However when testing applying the strategy on a chart, it never stays enabled because the strategy starts on past candles on the chart instead of the current one and closes the trade before the current candle starts. this causes the bool to flip on before my current trade is able to even play out.

    Is there a better way to achieve what i am trying to do? Or, is there a way to have the strategy not be applied to any of the prior data in a chart?

    #2
    Hello sra18376,

    Thanks for your post.

    You can disable the strategy with the Disable() method, please see: https://ninjatrader.com/support/help...7/?disable.htm

    You can "skip" historical trades by adding: if (Historical) return; at the top of OnBarUpdate(), this will prevent code below that line from processing until connected to live data.

    Reference: https://ninjatrader.com/support/help...historical.htm
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Gav_G, Today, 02:12 PM
    2 responses
    4 views
    0 likes
    Last Post Gav_G
    by Gav_G
     
    Started by Gav_G, Today, 01:41 PM
    0 responses
    5 views
    0 likes
    Last Post Gav_G
    by Gav_G
     
    Started by kweiss, Today, 01:21 PM
    0 responses
    5 views
    0 likes
    Last Post kweiss
    by kweiss
     
    Started by digibob, Yesterday, 06:45 AM
    2 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by cutzpr, Today, 08:44 AM
    0 responses
    3 views
    0 likes
    Last Post cutzpr
    by cutzpr
     
    Working...
    X