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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X