Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Only trade during the DayTime

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

    Only trade during the DayTime

    Hello, What code can I use to have my strategy only Enter a Trade during the Day Session?

    Thanks!!

    #2
    Try
    Set 'EntriesPerDirection' to 1 (single trade) ,if using strategy builder.

    https://ninjatrader.com/support/helpGuides/nt8/en-us/?using_a_time_filter_to_limit_t.htm

    session iterator(); A whole list to choose from
    OrderTypes() nt8. it depends on what type of trade you want use for the strategy. market order, limit, .....

    TradeCollection()
    protected override void OnBarUpdate()
    {
    // Print out the number of long trades
    Print("The strategy has taken " + SystemPerformance.AllTrades.Count + " trades.");
    }

    Enterlong()
    Example ,EnterLong(int quantity)

    rotected override void OnBarUpdate()
    {
    if (CurrentBar < 20)
    return;

    // Only enter if at least 10 bars has passed since our last entry
    if ((BarsSinceEntryExecution() > 10 || BarsSinceEntryExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
    EnterLong(5, "SMA Cross Entry");
    }
    Last edited by Emma1; 12-25-2018, 08:02 AM.

    Comment


      #3
      Hello r3n3v,

      Thanks for your post.

      You can control your strategy timing by using a time filter. The time filter provides an entry condition that basically says the time must be between this time and that time, that you specify.

      If you are coding directly in Ninjascript, here is a link to a working example: https://ninjatrader.com/support/help...to_limit_t.htm

      If you are using the strategy builder then you can check the help guide example, "How to create time filters" https://ninjatrader.com/support/help...on_builder.htm

      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ETFVoyageur, 05-07-2024, 07:05 PM
      6 responses
      50 views
      0 likes
      Last Post ETFVoyageur  
      Started by Klaus Hengher, Yesterday, 03:13 AM
      2 responses
      15 views
      0 likes
      Last Post Klaus Hengher  
      Started by Sebastian - TwinPeaks, Yesterday, 01:31 PM
      2 responses
      13 views
      0 likes
      Last Post Sebastian - TwinPeaks  
      Started by wbennettjr, 07-15-2017, 05:07 PM
      16 responses
      2,533 views
      1 like
      Last Post eladlevi  
      Started by Human#102, Yesterday, 09:54 AM
      2 responses
      8 views
      0 likes
      Last Post Human#102  
      Working...
      X