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

EMA from higher timeframe

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

    #16
    Hello Johnny,

    What is the time and date of the first bar and second bar printed from the script?

    What is the time and date of the first bar and second bar on the chart that has the indicator directly applied?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Hello Chelsea,

      Indicator to chart:
      Bar 1: May, 5th at 3:30 am
      Bar 2: May, 5th at 3:40 am

      Indicator in strategy:
      Bar 1: May, 10th at 02:00 am
      Bar 2: May, 10th at 02:00 am

      playback set to May, 15th

      Best regards,
      Johnny

      Comment


        #18
        Hello Johnny,

        If the first bars printed from the script and the first bar on the chart doesn't match, then the data is not the same.

        Either its a different data series or the time frame is different..

        Different data means different results.

        What is the data series used for the script?
        What is the Days to load or Date range used for the script?
        What is the data series use for the chart?
        What is the Days to load or Date range used for the chart?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Hi Chelsea,

          steps to reproduce:

          1. Setup playback connection with loaded market replay data
          2. Open NQ Chart on 10 minute timeframe. Set playback to May, 14th.
          3. Set Data series with "Days to load" to 30.
          4. Add Indicator to chart "EMASecondarySeries" with Period 60 and change color to blue.
          5. Add Strategy to chart "EmaSecondaryStrategy" (change Period also to 60 in code behind so the values should be the same).
          6. Set "minimum required bars" to 500 (It doesn't make any differences in calculation)
          6. Activate the strategy to see the result:
          Click image for larger version

Name:	result.png
Views:	170
Size:	38.0 KB
ID:	1059717


          How do I set up the strategy correctly?

          Best regards,
          Johnny




          Comment


            #20
            Hello Johnny90,

            If the data is the same and the indicator parameters are the same, the indicator values will be the same.

            Below is a link to a video that demonstrates.


            Below is a link to a video that demonstrates.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Hello Chelsea,

              1. The sample video is with different indicator without "AddChartIndicator" method used in strategy.
              2. The calculation is based on BarsArray[1] witch is not possible with AddChartIndicator.
              3. Can you please reproduce the issue with my provided steps above? The indicator and sampleStrategy is from your post on Page 1.
              4. or could we do a TeamViewer Session to resolve this? Maybe that's the easiest way to resolve this faster. We could do this tomorrow or on friday.

              Best regards,
              Johnny

              Comment


                #22
                Hello Johnny,

                An indicator that uses BarsArray[1] as the input series cannot be added to the chart with add chart indicator.

                The video I prepared shows that an indicator using BarsArray[1] in post #20 shows that values from an indicator with BarsArray[1] matches a chart that is using the same series.

                The script in Post #10 does not use BarsArray[1]. This simply adds a secondary series to show this does not affect the values of an indicator using the primary series for values.

                What are you wanting me to test?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Hello Chelsea,

                  here's a video witch describes my problem from post #19. The script and strategy is from your post #10. I don't understand why there is any differences in calculation between the two indicators (same period, chart, etc.). One indicator manually added to the chart shows right values, while the same indicator used from strategy (with AddChartIndicator) generates wrong values.



                  Comment


                    #24
                    Hello Johnny90,

                    That was my mistake. In the code, I was just making a quick example that uses the secondary series. Its also necessary to change the logic so that the prior value is not from the previous primary bar but from the previous secondary bar.

                    Re-exported with the change.
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Hello Chelsea,

                      thanks for all your help, the values are correct now and the strategy is working in realtime mode.

                      When backtesting the strategy I encountered that the EMA Indicators need some time till the values are correct are therefore the backtesting results getting incorrect. How can I get rid of this behavior?
                      Click image for larger version

Name:	backtest.png
Views:	174
Size:	88.3 KB
ID:	1062822

                      Best regards,
                      Johnny

                      Comment


                        #26
                        Hello Johnny,

                        Are you referring to the BarsRequiredToPlot?

                        This defaults to 20. You can set it lower.

                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Hello Chelsea,

                          sorry the problem was related to my custom code.

                          Thanks!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by bortz, 11-06-2023, 08:04 AM
                          47 responses
                          1,606 views
                          0 likes
                          Last Post aligator  
                          Started by jaybedreamin, Today, 05:56 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post jaybedreamin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          6 responses
                          18 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by Jon17, Today, 04:33 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post Jon17
                          by Jon17
                           
                          Started by Javierw.ok, Today, 04:12 PM
                          0 responses
                          13 views
                          0 likes
                          Last Post Javierw.ok  
                          Working...
                          X