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 CarlTrading, Yesterday, 11:51 AM
    0 responses
    12 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, Yesterday, 11:48 AM
    0 responses
    19 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-25-2026, 09:53 PM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 03-25-2026, 09:51 PM
    0 responses
    13 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 03-23-2026, 11:13 AM
    0 responses
    18 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X