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 iceman2018, Today, 08:55 PM
    0 responses
    1 view
    0 likes
    Last Post iceman2018  
    Started by mrmccraig, 04-24-2025, 05:13 PM
    4 responses
    34 views
    0 likes
    Last Post mrmccraig  
    Started by anthonyruhuti, Today, 08:03 PM
    0 responses
    2 views
    0 likes
    Last Post anthonyruhuti  
    Started by michelz, 02-18-2025, 08:30 AM
    37 responses
    1,084 views
    0 likes
    Last Post rockmanx00  
    Started by ericashannon83, Today, 06:27 PM
    0 responses
    3 views
    0 likes
    Last Post ericashannon83  
    Working...
    X