Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Weekly Bars from Minute data

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

    Weekly Bars from Minute data

    Hi!

    I want to add Weekly Bars built from Minute data as secondary bar series in my Strategy. I have the following code:

    Code:
    else if (State == State.Configure)
    {[INDENT]AddDataSeries("ES 03-22", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 10080 }, "Default 24 x 7", false);[/INDENT]
     
    
     }
    The problem is that it builds the weekly bar from Wednesday to Wednesday 6am. I want it from Sunday 12pm to Sunday 12pm. How can I achieve this?

    A custom trading hour template is not possible because it doesn't allow a session to be more than 24 hours.


    Thanks in advance!
    Last edited by KirkHammett; 12-27-2021, 03:03 PM.

    #2
    Hello KirkHammett,

    Thanks for your post.

    To have full control over when the bar starts and stops, and to span multiple days, I may suggest creating your own Weekly BarsType that uses minute data instead of daily data.

    You could consider creating a new BarsType based on the existing Weekly BarsType, and you can start by changing BuiltFrom to BarsPeriodType.Minute so your new modified BarsType uses minute data.

    Additional changes would be needed to have the logic create new bars based on the date and time being Sunday at 12pm.

    AddBar is used to signal the bar is closed and to start developing the next bar, while UpdateBar is used to update the current bar with new High Low Close and Volume.

    BarsType documentation - https://ninjatrader.com/support/help.../bars_type.htm

    Then, when adding the custom bar to the script, you would do the following:

    AddDataSeries((BarsPeriodType)123456, 10);

    where '123456' is the BarsPeriodType index of the custom BarsType.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X