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

Dynamic base pointer or time reference for secondary time interval

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

    Dynamic base pointer or time reference for secondary time interval

    Is there a way to have a strategy use a rolling or moving pointer for the tick array/values reference when you are referencing another time interval?

    Currently when you add another time interval reference is makes that a static reference the same as a chart for the strategy. For example you add a 50 tick reference it will establish a 50 tick time line that is every 50 ticks. What I want is the last 50 ticks not every 50 ticks.

    Can I do this?

    If I can add and remove the second instrument interval it may help but on a chart it picks a random start point and does not always use the current tick as a starting point.

    Cliff

    ps: I hope I worded this ok.

    #2
    Not sure I follow...

    If you want to see where - on a multi series strategy - the current bar "pointer" is for a different series than the one in progress, then check out:
    CurrentBarsArrays[<seriesToLookAt>] yields the "current bar" index for any series of a strategy.

    Comment


      #3
      Dierk

      Sorry I did a bad job of explaining.

      Scenario:

      I add a 50 tick instrument to a 1 minute chart.
      I want to know the EMA(13) value.
      I want the ema(13) value of the last 50 ticks. Not the current bar of a bar that is 25 ticks of a 50 tick bar.

      Currently it gives the value/bars for up to 50 ticks just like a chart. The values changes over the 50 ticks and starts over every 50 ticks using a fixed point as the where the 50 ticks start. I want the EMA(13) bar of the last 50 ticks, 100 ticks, etc. I don't want the last 13 bars or a static starting point.

      It is like I want the values/bars are re-computed back each time using the current tick as tick [0] to build the bars. Tick counter or Ticks remaining 0 each time. If you had a chart actually running this logic your bars and values might change each tick because 1 tick rolled to the previous bar each time.

      Imagine a 50 tick chart that recalculated every bar as if the current tick was tick number 50 (in my example).

      Is this any help?

      Comment


        #4
        >> I add a 50 tick instrument to a 1 minute chart.
        Not possible. Still don't follow

        Comment


          #5
          I add this to a 1 minute strategy.

          Add(PeriodType.Tick, 50);
          InstrumentPosition.Add("50-Tick", 1);

          Comment


            #6
            Let's try to find some solid ground:
            - you are running a multi-series strategy on a 1 minute chart, no?
            - the secondary series you want to add is running on a 50 ticks series, no?
            - there is no property/method "InstrumentPosition" available at the strategy. Not sure what you want to do with: "InstrumentPosition.Add("50-Tick", 1);". This code will not compile.

            Using this setup you can:
            - access the EMA(13) of your primary (1-minute) series by: EMA(BarsArray[0], 13)[<barsAgo>]
            - access the EMA(13) of your secondary (50 ticks) series by: EMA(BarsArray[1], 13)[<barsAgo>]

            Comment


              #7
              Let's try to find some solid ground:
              - you are running a multi-series strategy on a 1 minute chart, no?
              Yes.
              - the secondary series you want to add is running on a 50 ticks series, no?
              Yes.
              - there is no property "InstrumentPosition" available at the strategy. Not sure what you want to do with: "InstrumentPosition.Add("50-Tick", 1);". This code will not comppile.
              There is other code required. I added it for clarification. It was the reverse.

              Using this setup you can:
              - access the EMA(13) of your primary (1-minute) series by: EMA(BarsArray[0], 13)[<barsAgo>]
              - access the EMA(13) of your secondary (50 ticks) series by: EMA(BarsArray[1], 13)[<barsAgo>]
              ok, I want to use this series, the secondary 50 tick.

              Can I get this series to re-establish "ticks remaining" to zero each time? Last tick the current bar was calculated on ticks 0 - 49. Bar [1] was calculated on ticks 50 to 99. The current tick I want the same offsets (0 to 49) to happen but the bars moved 1 tick. In the normal scenario if the last tick was tick 50 of 50. Bar [0] would be calculated on just tick [0] not [0] to [49].

              I can start a 50 tick and you can start a 50 tick chart. Our tick zero or base pointer can be different. We both look at a different 50 ticks. This is normal. I want to have my bars/values calculated from the secondary series as if the last tick is always tick 50 of 50. Not tick 25 of 50 or tick 37 of 50. All bars/values would be recalculated every tick. The values on bar [1] could have changed because it's 50 ticks changed or moved up 1 tick. It dropped the previous last tick and added the next tick forward.

              I really hope this helps. I will let you call it quits if this doesn't help. I think my terminology is not perfect. I must be making you crazy.

              Comment


                #8
                Hi Cliff,

                Sorry, both Dierk and I are at a loss in comprehending your post.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Thanks Ray I will call it quits.

                  Comment


                    #10
                    Please let me try, as I think I got the point of the initial question.

                    Imagine a truck pulling 3 trailers, and it is picking up traffic cones after road works are complete. The capacity of each trailer is 50 cones, and as each cone is picked up it will always be placed into the first trailer (trailer[0]). When the 51st cone is placed into trailer[0], the first cone picked up is pushed onto the trailer behind (trailer[1]). As each new cone goes into trailer [0], one cone has to move into trailer[1]. When trailer [1] is full, then that very first cone is passed from trailer[1] to trailer[2], and so on. When all trailers are full, then each new cone into trailer[0] results in one falling off the back of trailer[2].

                    Pretty stupid I know, but you should see the road workers where I live......

                    So for every new tick that is received, all prior bars have one tick passed backwards, and all the bars have to be recalculated for the length of the lookback period. Bar[0] will always contain 50 ticks.

                    'ct' wants EMA(13) for this type of dataseries.

                    Hope I got that right, but even so I think the response will be a short one.

                    Comment


                      #11
                      >> Bar[0] will always contain 50 ticks
                      Incorrect, that not how it works. Bar[1], Bar[2]... always have 50 ticks.
                      Bars[0] has between 1 and 50 ticks. There is no way around.

                      -> no need to recalculate older bars

                      Comment


                        #12
                        MJT

                        You got it! It is a rolling EMA.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by JonesJoker, 04-22-2024, 12:23 PM
                        6 responses
                        32 views
                        0 likes
                        Last Post JonesJoker  
                        Started by GussJ, 03-04-2020, 03:11 PM
                        12 responses
                        3,239 views
                        0 likes
                        Last Post Leafcutter  
                        Started by AveryFlynn, Today, 04:57 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post AveryFlynn  
                        Started by RubenCazorla, 08-30-2022, 06:36 AM
                        3 responses
                        79 views
                        0 likes
                        Last Post PaulMohn  
                        Started by f.saeidi, Yesterday, 12:14 PM
                        9 responses
                        25 views
                        0 likes
                        Last Post f.saeidi  
                        Working...
                        X