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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 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
    45 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