Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trades Not Exiting

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

    Trades Not Exiting

    I have a strategy setup in SA, working properly. But I want to tweak the entry/exit criteria a little depending on if the stock is trending up or down. When my trend criteria is met, a bool variable (upTrend) is set to true.

    The code is working and my Entries are correctly triggered when my (upTrend) criteria is met.

    But, if I go long the trend and that trend ends while still in my trade, my strategy won't exit until the next upTrend starts and the exit criteria is met during the new trend.

    Conversely, if a trend starts while I'm in a position triggered by my normal trading criteria, the (upTrend) exit rule kicks in. How can I keep these two rule from overlapping?

    I know it's something simple but I can't think through it. Here is my trend code:

    //****Trading During Uptrend****
    if (upTrend)
    {

    if (DoubleStochastics(DD).K[0] > DoubleStochastics(DD).K[1])
    {
    EnterLong(DefaultQuantity, "Trend Up");
    }

    if (Momentum(Sell)[0] < Momentum(Sell)[1])
    {
    ExitLong("DownDay","Trend Up");
    }

    }

    #2
    Hello reticent67,
    To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

    Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

    I look forward to assisting you further.

    *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    77 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    27 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    62 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X