• 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 gemini42, Today, 01:53 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by asmmbillah, Today, 04:42 PM
    2 responses
    11 views
    0 likes
    Last Post asmmbillah  
    Started by JAtrades, Today, 02:44 PM
    3 responses
    12 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by mr_trade, Today, 01:32 PM
    1 response
    11 views
    0 likes
    Last Post Emma1
    by Emma1
     
    Started by sgordet, Today, 10:44 AM
    1 response
    13 views
    0 likes
    Last Post bltdavid  
    Working...
    X