Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating an overridden series value

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

    Creating an overridden series value

    I am trying to use one of your indicator methods but I want to update the close from another timeframe.

    My understanding is that I can copy the series from another timeframe via the BarsArry:

    For example, say I want to alter Timeframe2's indicator value return for SMA because I have 1 and 15 min timeframes and read the new 15min timeframe value from the 1 min OnBarUpdate:

    First I copy TimeFrame 2's into a series:
    var myEmptyIndexedSeries = new Series<double>(BarsArray[timeframe2]);

    but how do I update the Close value of the latest bar from Timeframe 1?
    I have tried a few things but I can't figure it out.

    then I call the SMA with the changes series to get my altered value:
    smaValue2 = SMA(myEmptyIndexedSeries, 14)[0];

    any assistance is greatly appreciated.

    #2
    Hello MarketAlly,

    Thank you for your post.

    I am not sure I fully follow you here. Are you looking for the indicator on the primary bar series (time frame 1) to update intra-bar by using a secondary bar series (time frame 2)?
    Is this for historical data and backtesting?

    Comment


      #3
      this is realtime - what I have is 2 time frames - a 1 minute and a 15 minute. My issue is I want to do processing on the 15 time frames value but I need the sensitivity of the 1 minutes latest value.

      So during the time in between the next 15 minute bar - my 1 minute OnBarUpdate executes 14 times - I would like the recalculate the SMA of the 15 min timeframe with the latest close value. for processing during the 1 minute update. I noticed the 15 minute bar's value doesn't update to the latest Close (I cannot use tick for processing reasons) so I would like to manually update it to get my new value.

      Comment


        #4
        Hello MarketAlly,

        Thank you for your response.

        You should only need one DataSeries that you add that is synced to the primary (15 minute) bar series. Update that DataSeries index 0 on the 1 Minute bar updates. If you provide your code, I can try to put together an example for you.

        Comment


          #5
          Can we psudo it here?

          1 min - initial
          15 min added


          During 1 minute OnBarUpdate()
          {
          ....

          int timeframe2 = 1;

          var myEmptyIndexedSeries = new Series<double>(BarsArray[timeframe2]);
          myEmptyIndexedSeries[0] = Close[0]; //<-- I do not think this is right.
          smaValue2 = SMA(myEmptyIndexedSeries, 14)[0];


          ....
          }

          Comment


            #6
            Hello MarketAlly,

            In the case of something like the SMA we could not just call the SMA(period)[0] data series as it has already been set based on the specified series and calling a secondary series as the input is only going to call the full SMA(period) across the secondary series.

            So you set the DataSeries in your code to the calculation needed. For example, below is the code of the SMA using this concept appropriately:
            Code:
            protected override void OnBarUpdate()
                    {
            			if(BarsInProgress == 0)
            			{				
            				if (CurrentBars[0] == 0)
            					myDataSeries[0] = Closes[0][0];
            				else
            				{
            					double last = myDataSeries[1] * Math.Min(CurrentBars[0], Period);
            
            					if (CurrentBars[0] >= Period)
            						myDataSeries.Set((last + Closes[0][0] - Closes[0][Period]) / Math.Min(CurrentBars[0], Period));
            					else
            						myDataSeries.Set((last + Closes[0][0]) / (Math.Min(CurrentBars[0], Period) + 1));
            				}
            			}
            			
            			if(BarsInProgress == 1)
            			{
            				if (CurrentBars[1] == 0)
            					return;
            				else
            				{
            					double last = myDataSeries[1] * Math.Min(CurrentBars[0], Period);
            
            					if (CurrentBars[0] >= Period)
            						Value.Set((last + Closes[1][0] - Closes[0][Period]) / Math.Min(CurrentBars[0], Period));
            					else
            						Value.Set((last + Closes[1][0]) / (Math.Min(CurrentBars[0], Period) + 1));
            				}
            			}
                    }

            Comment


              #7
              Hi Patrick,
              I hate to interject here but I believe MarketAlly is asking for a way calculate the SMA on the higher time frame data series with Partial bar updates (i.e every minute) "without" having to recode the SMA indicator as you did in your example. Imagine instead of an SMA calculation you want to run a linear regression. Suddenly not so trivial. For me this is one of the biggest shortcomings in NT.

              Comment


                #8
                Thanks for the clarification, GrumpyTrader.

                I will forward this suggestion to our development team.

                Comment


                  #9
                  Originally posted by GrumpyTrader View Post
                  Hi Patrick,
                  I hate to interject here but I believe MarketAlly is asking for a way calculate the SMA on the higher time frame data series with Partial bar updates (i.e every minute) "without" having to recode the SMA indicator as you did in your example. Imagine instead of an SMA calculation you want to run a linear regression. Suddenly not so trivial. For me this is one of the biggest shortcomings in NT.
                  You would Add the higher timeframe as a BarSeries, and then calculate the indicator that you want on BarsArray[1].

                  As trivial (or not )as any other multi timeframe indicator.

                  Comment


                    #10
                    Hi Koganam,
                    I could be missing something but I quite certain I'm correct. If I add a high time frame dataseries it will only be updated on the close of bar for that dataseries.

                    For example, if I am trying to simulate a close order on daily bars, so I want a calculation based on the daily series but updated a minute before the close of that series using the partial daily bar at that time.

                    In live trading, using CalculationMode OnTick or PriceChange will give you a partial bar value, but there is no easy way to simulate that in backtesting.

                    I was hoping that the higher resolution backtesting would allow for that but it doesn't create lower timeframe OnBarUpdates or partial bar calculation.

                    I hope I'm missing something because that would simplify my life.

                    Comment


                      #11
                      This is being tracked under id SFT-1129.
                      Originally posted by NinjaTrader_PatrickH View Post
                      Thanks for the clarification, GrumpyTrader.

                      I will forward this suggestion to our development team.

                      Comment


                        #12
                        How do I find reference online to SFT-1129?

                        Comment


                          #13
                          Hello MarketAlly,

                          SFT-1129 is the internal tracking number for the feature request. There would not be any documentation on the SFT id.

                          Comment


                            #14
                            is there any way to find out status in the feature queue? Being able to re-evaluate the series to get current values for indicators on other timeframes is impacting us. If a work around is available, we would gladly do it to arrive at the updated value.

                            Comment


                              #15
                              Hello MarketAlly,

                              Thank you for your response.

                              The status at this point is that requests for this feature are being tracked. While it is being tracked there is no guarantee this will be implemented at this time.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Shansen, 08-30-2019, 10:18 PM
                              25 responses
                              949 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by JonesJoker, 04-22-2024, 12:23 PM
                              8 responses
                              41 views
                              0 likes
                              Last Post JonesJoker  
                              Started by timko, Today, 06:45 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post timko
                              by timko
                               
                              Started by Waxavi, 04-19-2024, 02:10 AM
                              2 responses
                              39 views
                              0 likes
                              Last Post poeds
                              by poeds
                               
                              Started by chbruno, Yesterday, 04:10 PM
                              1 response
                              44 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X