Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy executes trade when conditions are wrong

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

    strategy executes trade when conditions are wrong

    I am having a puzzling time figuring out some NT performance errors. I have a simple strategy that enters a LONG trade when several indicators are all moving UP. The reverse is true for SHORT trades. However, I am finding several instances where NT executes a LONG trade when the SMA is actually going DOWN. Yikes! I have attached a screen shot to illustrate. The gold line is the SMA of price. It is clearly going DOWN, but NT executes a LONG trade. Here is the code from the strategy:

    protected override void OnBarUpdate()
    {...
    double sma1 = SMA(Close, periodMovingAverage)[1];
    double sma0 = SMA(Close, periodMovingAverage)[0];
    ...
    bool HigherSMA = false;
    ...
    if(sma0 > sma1)
    HigherSMA = true;
    ...
    If(HigherSMA)
    {EnterLongLimit(...)}

    Any ideas why NT enters a LONG trade when the condition is visibly not met? I have confirmed the action by manually observing the SMA values in the data box. SMA is definitely going down, not up.

    Thanks for your feedback,
    D
    Attached Files

    #2
    You should print the values of your bools each step of the way and isolate what is happening under the hood.

    Print(HigherSMA);
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X