Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Only one trade per day problem

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

    Only one trade per day problem

    Hi,

    I am trying to backtest a strategy but only make one trade per day. I found the following post:



    and used the following code:

    Code:
    OnBarUpdate()
    {
       if (CurrentBar < 2) return;
       if (Time[0].DayOfWeek != Time[1].DayOfWeek) // new day, reset bool flag
       {   alreadyTradedToday = false; }
    
       if ([Long Entry Conditions are true] && alreadyTradedToday == false)
       {
          alreadyTradedToday = true;
          EnterLong();
       }
    }
    This code seems like it is somewhat working because when I used this, there are far fewer trades than when I didn't. Most days there is only one trade. However, there are some days that have multiple trades (2-4 trades) that go off. Is there anything special I need to do when backtesting?

    Thanks.

    #2
    The code here looks like it operates off of the calendar day of the week instead of the session template which would explain why you may see more than one trade on some days.

    Try using this sample instead to limit trades: http://www.ninjatrader.com/support/f...ead.php?t=4084

    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    61 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    39 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    21 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    23 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    51 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X