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

Indicator and custom DataSeries

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

    Indicator and custom DataSeries

    Hello,

    I am trying to run an indicator with custom DataSeries, where I want to pass current bars' every tick as value.

    For example, this is how EMA can be calculated: EmaValue = EMA(Close, 3)[0]; This logic will use Close price of every bar in calculation over last 3 bars. I want to check what would be EMA value for every tick on my current bar. So I defined custom DataSeries, where I populate previous bars (positions 1 and 2) with Close[1] and Close[2]. Then I do a "for" loop to populate 0 position in custom DataSeries with every tick of the current bar.

    Let's say the current bar's High was 1950 and Low was 1940 (for ES emini).

    My custom DataSeries would look as follows on the 1st run of the loop:
    1950 (current bar High) - index 0
    1945.50 (previous bar close) - index 1
    1935.50(bar before previous bar close) - index 2

    It would look as follows on the 2nd run of the loop:
    1949.75 (current bar High minus 1 tick) - index 0
    1945.50 (previous bar close) - index 1
    1935.50(bar before previous bar close) - index 2

    And so on, until every tick of the current bar is passed in index position 0. As you can see, only index position 0 changes in custom data series. I would assume that EMA value would be a bit different each time it calculates, since first value (index 0) in custom dataseries changes for each calculation.

    But, EMA value stays exactly the same for every calculation. Any idea why?

    Thanks,
    redduke
    Last edited by RedDuke; 10-16-2014, 09:47 PM.

    #2
    Hi redduke, so I understand the on this short EMA the values could be expected to change and you see those updating if the default EMA is run on COBC = false?

    The same item was also discussed here, with a solution offered to custom dispose the EMA to force a value regeneration on your custom series - http://www.ninjatrader.com/support/f...ad.php?t=48170
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks a lot for the link.This fixed my issue of recalculating the value for each tick. Are you aware of any performance issues with using Dispose? If I let indicator loose on every bar and have displose calculating of every tick, the indicator is hanging. It could be some bug which I will find through debug, but just want to check in case you are aware of anything?

      Thanks a lot,
      redduke

      Comment


        #4
        redduke, glad to hear - I'm not directly aware of anything, so would be worth to isolate out further. If you would though look into just returning out of updating your items for same value ticks. So only focus on the changes, this should be easing things up.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks. Debugging it is then

          When I tried to expand DataSeries object in Visual Studio debugging, I could not figure out where the values array is stored. This object has so many attributes. Would you know which attribute contains values of dataseries array?

          Thanks

          Comment


            #6
            RedDuke,

            The BarsArray collection is available through the ChartControl. This is your best bet for getting those values
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hi Cal,

              I am talking about my custom DataSeties object that I use for calculations of an indicator. I stored some values there, but can not figure out which attribute has them when I expand the object in visual studio debugging. I can manually retrieve them, but debugging locals window makes it easier.

              Thanks,
              Redduke

              Comment


                #8
                RedDuke,

                Can you give me a screenshot of what you are seeing in the Visual Studio.

                Please keep in mind that Visual Debugging is not supported with NinjaTrader, so we will need to go at this one step at a time to check the right values.
                Cal H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by firefoxforum12, Yesterday, 08:53 PM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by kmunroe478, Yesterday, 05:39 PM
                2 responses
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by kevinenergy, 02-17-2023, 12:42 PM
                115 responses
                2,699 views
                1 like
                Last Post kevinenergy  
                Started by prdecast, Today, 06:07 AM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Christopher_R, Today, 12:29 AM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X