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

Indicator values in Multi Time Frame strategy

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

    Indicator values in Multi Time Frame strategy

    Hi there,

    I have developed a strategy that runs on daily bars. I have coded it to do what I want it to do and it executes trades in the Strategy Analyzer as I would expect. It primarily uses Bollinger bands and looks for multiple closes below the Bollinger bands and then looks to enter on a close above the lower band.

    In version 2 of this strategy I have added a second data series (1 minute) and am working on a Draw.ArrowDown and a Draw.Text alert to appear at the end of the trading day BEFORE the trade executes at the open the following morning.


    I have set the Calculate to OnPriceChange

    I have added the following code to get the close of the 3:59 bar as an approximation of the close.

    if (BarsInProgress == 1)
    {
    if (IsFirstTickOfBar)

    {


    if(ToTime(Time[0]) >92900
    &&
    ToTime(Time[0]) <155900)
    {
    EOD=false;
    }
    else if (ToTime(Time[0]) >=155900)
    {
    EOD=true;
    }


    if (EOD==true)
    {
    LastMinuteClose = Close[0];
    Print(Time[0]+"The current 5 minute close is : " + LastMinuteClose);
    }


    The problem I am having is getting the Bollinger Band Values for the current day (based on the daily time frame) at the 3:59 time stamp as they should be on the daily bars(if calculating OnPriceChange) and not on the Close of the daily bar.


    Once I have the LastMinuteBar price I would like to compare it to the Daily Lower Bollinger Band price for today calculated at 3:59, not the day prior.

    I have tried several methods and have used a print in the IsFirstTickOfBar on the one minute bar series including a data series and a bars array, but It only seems to reference the prior day Lower Bollinger Band value calculated at the close of the prior days bar. The Value for each 1 minute bar matches the close of the prior daily bar BB.Lower value


    I have reviewed this thread: https://ninjatrader.com/support/foru...ng-minute-data


    and this thread: https://ninjatrader.com/support/foru...aily-bar-close


    The first thread though for Ninja 7 would seem to indicate the indicator logic has to be loaded in both time frames to get these values calculated. I am not exactly sure how to load the bollinger band indicator in the 1 minute Bars in Progress, but have it calculate the daily bar value OnPriceChange. The second thread seems to indicate adding this secondary time frame is the way to go.

    I am clearly missing something here. Any help would be appreciated.



    #2
    Hi stalt, thanks for your question.

    I attached an example that hosts a Bollinger applied to the secondary time frame for your reference.

    Note that a daily bar will only have 1 timestamp. A daily bar's timestamp is the time of closing. To get millisecond time stamps on a bar series you would need to use tick-based bars.

    Please test the script with Tick Replay enabled. This will accurately return the first tick for the daily bar that has not yet closed (when tick replay is off, the FirstTickOfBar will happen on the first real-time tick because it's literally the first tick of the bar after loading historical data).

    Please let me know if I can assist any further.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Austiner87, Today, 03:42 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by cshox, Today, 11:11 AM
    2 responses
    15 views
    0 likes
    Last Post cshox
    by cshox
     
    Started by algospoke, Today, 06:53 PM
    0 responses
    9 views
    0 likes
    Last Post algospoke  
    Started by mlprice12, 12-21-2021, 04:55 PM
    3 responses
    296 views
    0 likes
    Last Post paypachaysa  
    Started by lorem, 04-25-2024, 09:18 AM
    20 responses
    86 views
    0 likes
    Last Post lorem
    by lorem
     
    Working...
    X