Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

1minute close on 5 minute chart or price

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

    1minute close on 5 minute chart or price

    NinjaTrader Support,

    I'm trying to figure out how to trigger orders before bar (5 minute or 10 minute, etc...) closes.
    How would I program a strategy to trigger an order using 1minute price close on 5 minute chart?
    Is it possible to use real-time price data to trigger 5 minute variable such as Bollinger Band?
    I'm not sure if high or low data is "live" and can trigger orders before bar close.

    ie/ Price is above BollingerBand (5m) = submit sell order

    Currrent
    if ((Close < Bollinger.Lower)
    {
    EnterLong(10, @"BuyLong");
    ExitShort(10, @"SellShort","");
    }

    Hoping for:
    if ((Price/Low/Close [1m] < Bollinger.Lower)
    {
    EnterLong(10, @"BuyLong");
    ExitShort(10, @"SellShort","");
    }

    Your help is very much appreciated

    #2
    Hello Blairski,

    Thanks for your post.

    There are a couple of approaches you could take.

    If you set your strategy to Calculate.OnEachTick then Close[0] will represent the current price of the forming bar so this gives you real time data response. So when Close[0] crosses the Bollinger band you can instantly submit an order. The downside of this is that you would need to implement additional coding to prevent multiple orders caused by the entry conditions becoming true multiple times within a bar. A simple way to limit one order per bar is:

    if (Your entry conditions && CurrentBar != savedBar)
    {
    // entry order
    savedBar = CurrentBar; // assign current bar number to integer variable "savedBar"
    }


    In the above example, using the user created variable savedBar, the code block is entered the first time your conditions are true and if the Current bar number is not the same as savedBar. Upon entry of the code block, any orders you have would be placed and the variable savedBar is assigned the value of CurrentBar which will prevent further entry into the code block until the next bar.


    Alternatively, you can add 1 minute bars and check to see if their close crosses the Bollinger band of the 5 minute bar.

    To add a data series, see: https://ninjatrader.com/support/help...dataseries.htm

    In the OnBarUpdate section you would likely want to:

    if (BarsInProgress == 1) // check on the close of the 1 minute bars
    {
    if (CrossAbove(Close, Bollinger(Closes[0], 2, 14).Upper)) // did the 1-minute bar cross above the 5 minute bollinger (note closes[0] points to 5 minute chart bars)
    {
    // enter order on the 1 minute bar
    }
    }

    Adding a data series creates a multi time frame strategy which has very different and specific considerations that are addressed in the following section: https://ninjatrader.com/support/help...nstruments.htm

    In addition, for the entry methods used, please review for the advanced order handling overload so you can submit to the 1 minute bars object.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X