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

Multiple Start Aggregation Periods on Same Symbol

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

    Multiple Start Aggregation Periods on Same Symbol

    I am running a strategy on NQ Nasdaq Futures using a 2 hour bar. The trading hours are set to CME US Index Futures ETH. the start time is 5pm and the end time is 4pm the next day.

    with these settings I get a bar that ends at 5pm - 7pm - 9pm etc...

    I would like to add to this strategy by using a 2 hour bar that ends on a different time rotation. Basically have the bar close at 6pm - 8pm - 10pm etc...

    I was going to change the trading hour template but that doesn't allow me to run both start times.

    Is it possible to run a bar with the same aggregation period that begins and ends on different time periods on the same instrument.

    Thank you

    Stefan

    #2
    Hello sdauteuil,

    It is not currently possible to stagger the series like this using the same series. It would likely be easiest to instead use a 60 minute bar and add a logical switch to check this. For example each 1 hour change a bools value to the opposite value. If the bool is true, do one set of logic, and if the bool is false do the other set. This would cause alternating times to be used in the frequencies you noted. Here is a simple example:

    Code:
    bool isSecondLogic = false;
    protected override void OnBarUpdate()
    {
          isSecondLogic = !isSecondLogic;
    
          Print("isSecondLogic " + isSecondLogic + " " + Time[0]);
     }
    Which looks like:

    isSecondLogic False 7/24/2019 5:00:00 PM
    isSecondLogic True 7/24/2019 6:00:00 PM
    isSecondLogic False 7/24/2019 7:00:00 PM
    isSecondLogic True 7/24/2019 8:00:00 PM
    isSecondLogic False 7/24/2019 9:00:00 PM


    The isSecondLogic
    bool could be used after that point to do one or the other sets of logic.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you

      I will work with that

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by benmarkal, Yesterday, 12:52 PM
      3 responses
      23 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by helpwanted, Today, 03:06 AM
      1 response
      20 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      11 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      244 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Working...
      X