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
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Franck Z, Today, 09:49 AM
    0 responses
    4 views
    0 likes
    Last Post Franck Z  
    Started by pvtrader, Today, 08:02 AM
    2 responses
    7 views
    0 likes
    Last Post pvtrader  
    Started by Natoc, Today, 03:04 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by Rudy2323, Today, 02:56 AM
    2 responses
    27 views
    0 likes
    Last Post Rudy2323  
    Started by tonynt, Yesterday, 02:07 PM
    1 response
    34 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X