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 arvidvanstaey, Today, 02:19 PM
    4 responses
    11 views
    0 likes
    Last Post arvidvanstaey  
    Started by samish18, 04-17-2024, 08:57 AM
    16 responses
    60 views
    0 likes
    Last Post samish18  
    Started by jordanq2, Today, 03:10 PM
    2 responses
    9 views
    0 likes
    Last Post jordanq2  
    Started by traderqz, Today, 12:06 AM
    10 responses
    18 views
    0 likes
    Last Post traderqz  
    Started by algospoke, 04-17-2024, 06:40 PM
    5 responses
    47 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X