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

Multi_timeframe question

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

    Multi_timeframe question

    Hi,

    I've studied the tutorial at this link:


    In it, is described the behavior of adding a second, longer timeframe data series. I would like to understand how adding a secind, SHORTER series works.

    Here is what I want to understand: My primary data series is a Range bar. I want to add a Tick series. The strategy is set to work on bar close. So, in the section of code where I'm accessing the Tick series (assuming set to 1 tick) will this mean that the onBarUpdate is done every tick (because it's a 1 tick series) until the close of the Range bar primary series?

    Or, would just the first close of the first tick in the faster series be the trigger to move on to the next onBarUpdate for the primary Range bar series.

    Hope this makes sense.

    #2
    Hi coolmoss,

    Each series in the strategy receives updates independently. The article you link shows how the additional series are referenced within this model.

    To define which series raises OnBarUpdate(), you can use BarsInProgress filters.


    The time stamps of bars is critical to seeing the sequence of OnBarUpdates(). To get an idea how the added series relate you could use something like this:
    Print("Bip: " + BarsInProgress + " " + Time[0]);

    Since there are different referencing models in historical and real time(cobc = false), try that print statement in both environments to get a feel for this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan

      Comment


        #4
        Okay, I have studied several references about using multi-time frames. It has helped, but I'm not sure if the approach I want to try is progrmatically viable.

        Is something like this doable:

        if (BarsInProgress != 0)
        return;

        ... various other code which operates on BarsInProgress == 0....

        if (conditions which set up prior to an actual reversal) //this is still BarsInProgress ==0
        {
        go to the secondary data series and monitor conditions on that series UNTIL the next onBarUpdate for primary series}

        If this isn't clear, I'll try again, just trying to keep it short and focused on where my real challenge is. Thanks for any help you are able to provide.

        Comment


          #5
          Okay, I thought I made some progress. My strategy compiles, it still works the way it did before, but doesn't seem to run the code form the secondary bar series. Basically, what I have is something that runs on bar close and submits Stop orders for entry. That all works. My challenge was figuring out how to use the managed approach and get the strategy to do reversals. So, what I did was add this to the main section which runs under IF(BarsInProgress ==0) -

          if (Position.MarketPosition == MarketPosition.Short && long_signal == true)
          {
          revToLong = true;

          Just set a flagging variable to tell the faster bars array to do the reversal stuff. Then, on the secondary (faster) bars array I did this...

          if(BarsInProgress == 1)
          {
          if(revToLong == true && Position.MarketPosition == MarketPosition.Short && Close[0] > Highs[0])
          {
          EnterLong(1, "FIRSTTARGET");
          }

          I am trying to submit this market order on the fast timeframe when my flag variable is true, position is currently short, and the close on the faster timeframe is above the high of the most recently closed higher timeframe (barsarray[0]).

          Comment


            #6
            Hello coolmoss,
            Thanks for writing in and I am replying for Ryan.

            To enter a position on a different bars series please use the overload
            Code:
            EnterLong(int barsInProgressIndex, int quantity, string signalName)


            Please see this reference sample which demonstrates this http://ninjatrader.com/support/forum...ead.php?t=6652

            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Thank you very much, it looks very much like it's working as desired

              Comment


                #8
                Hello coolmoss,
                Glad to know everything is working fine at your end.
                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by alifarahani, Today, 09:40 AM
                6 responses
                36 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Kaledus, Today, 01:29 PM
                5 responses
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Waxavi, Today, 02:00 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by gentlebenthebear, Today, 01:30 AM
                3 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X