Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy on FDAX open bar

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

    Strategy on FDAX open bar

    Hi! I'm trying to make a strategy on first bar on FDAX index when it breaks out its high or its low but strategy enters after the second bar (on the third bar) and not after the firstbarofsession as I print on the code.

    ¿Any solution for this?

    Thanks!!!



    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Bars.IsFirstBarOfSession == true)
    {
    Mínimodelas8h = Low[0];
    }

    // Set 2
    if ((CrossBelow(Low, Mínimodelas8h, 1))
    && (Times[0][0].TimeOfDay <= new TimeSpan(8, 30, 0)))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), @"MBSRacorto");
    }

    // Set 3
    if (Bars.IsFirstBarOfSession == true)
    {
    Máximodelas8h = High[0];
    }

    // Set 4
    if ((CrossAbove(High, Máximodelas8h, 1))
    && (Times[0][0].TimeOfDay <= new TimeSpan(8, 30, 0)))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"MBSRalargo");
    }

    }
    }
    }

    #2
    Hello Eugenio,

    Thanks for your post.

    For live trading, you would need to set your strategy to Calculate.OnEachTick or Calculate.OnPriceChange to enter orders intrabar or when the entry conditions occur. Please note that this will cause your strategy to execute on each tick (or price change) which can cause unexpected results. You may wish to separate your strategy logic so that some parts execute on the close of the bar and other logic to occur on each tick. Here is a link to a reference example of how to do this:http://ninjatrader.com/support/forum...ad.php?t=19387

    If you are backtesting or viewing trades historically then the trades will show as you have seen because the strategy can only run in the Calculate.OnBarClose historically. What happens is that at the end of the bar your code is calculated and if a cross is determined then the entry order is placed but cannot be filled until the next bar. With NinjaTrader8 you can select High order fill processing which would allow you to use a faster secondary series which will provide more On Bar Updates and would allow for intrabar orders.
    Reference: http://ninjatrader.com/support/helpG...ical_fill_.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    131 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X