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

Pivots Indicator in code not matching the time zone of Pivots indicator on chart

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

    Pivots Indicator in code not matching the time zone of Pivots indicator on chart

    I wrote an Indicator that calls the Pivots Indicator like this:

    R2 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).R2[0];

    but something is odd...

    It doesn't always match the Pivots Indicator placed on a Chart that also calculates from Intraday data ... right now I'm testing on forex, I haven't tried it on futures yet.

    It seems to me that the pivot indicator in the code above is starting the day at a different time zone than the Pivot Indicator placed on a chart.

    Can someone explain how to get the Pivots indicator in code to be the same as the one on the chart... I assume the one on the chart is using the forex session template.

    The reason I suspect a time zone mismatch is because they agree on the levels during the trading day, but I noticed the mismatch at midnight local time (I think). I went to bed though so I'm not sure how long it lasted for.
    Last edited by NinjaCustomer; 11-25-2014, 09:16 PM.

    #2
    Hello NinjaCustomer,

    I've recreated your statement in an indicator and applied it and the pivots indicator to various instruments (futures and forex), various charts with various session templates and in every occurance the R2 matches.

    Can you share more of your set-up so I can more closely replicate the issue?
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi, that's good to know... as far as I know I basically described what was going on in terms of my code for calling the pivots

      but I think I better start observing again around that time to get a better understanding of what is going on.

      Maybe it might have something to do with the numbers of days back on my charts.. Since I have many charts I tend to keep them tight, like 5 or something.. I know that can be sometimes insufficient to get the numbers correctly calculated over the weekend - but this particular one that I noticed was in the middle of the week last week. Anyhow though I guess I will set all the charts to 10 or 14 days back or something.

      Although theoretically I don't understand why daily pivots would need anymore than say 3 consecutive days back to calculate

      I'll do more observing and try to track down the problem and let you know.

      I just assumed it had something to do with a wrong time zone or something since it occurred after midnight.

      Comment


        #4
        Hello NinjaCustomer,

        Thanks for your reply.

        The pivots indicator, when calculating from intraday data, need a minimum of 2 days (to display the pivots from the prior days data onto the current day).
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaCustomer View Post
          I wrote an Indicator that calls the Pivots Indicator like this:

          R2 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).R2[0];

          but something is odd...

          It doesn't always match the Pivots Indicator placed on a Chart that also calculates from Intraday data ... right now I'm testing on forex, I haven't tried it on futures yet.

          It seems to me that the pivot indicator in the code above is starting the day at a different time zone than the Pivot Indicator placed on a chart.

          Can someone explain how to get the Pivots indicator in code to be the same as the one on the chart... I assume the one on the chart is using the forex session template.

          The reason I suspect a time zone mismatch is because they agree on the levels during the trading day, but I noticed the mismatch at midnight local time (I think). I went to bed though so I'm not sure how long it lasted for.
          The mismatch is likely caused by the use of different session templates. Please make sure that you always use the session template <instruments settings>. If you use the pivots indicator with a session template such as 24/5 or 24/7 you will mostly get false pivots.

          If you use your own indicator, the session template is selected via the DataSeries settings of your chart. If you use your indicator with the strategy analyzer, then your session template needs to be selected via the dialogue box of the strategy analyzer.

          Comment


            #6
            I think I mostly somehow fixed it in the market analyzer...

            But I noticed that the values of the indicator on the chart go out of wack after midnight.

            I then must reload ninjascript and then the indicator will display the correct values again (matches the pivots made by the NT pivots indicator)

            Also for the market analyzer, I have to do this - reload the columns once after midnight and then it works fine again... strange thing though, i think after hours of running the market anaylzer will again display the correct values even without a reload of the columns .. (I'm not 100% sure about the market analyzer values correcting after hours without a reload, but I think yes... it is hard to tell you for sure because I have to wait for midnight to double-check that)

            So I'm wondering if anyone knows of a reason why a script would need to be reloaded on a chart every night after around midnight? This script calls the NT Pivots indicator to get values.. it does other things too, but the values that need to be reloaded are directly related to the NT pivots values.

            Comment


              #7
              Originally posted by NinjaCustomer View Post
              So I'm wondering if anyone knows of a reason why a script would need to be reloaded on a chart every night after around midnight? This script calls the NT Pivots indicator to get values.. it does other things too, but the values that need to be reloaded are directly related to the NT pivots values.

              The pivots indicators loads daily data asynchronously from the historical data base. A refresh of the chart does not trigger the download of daily data from your data provider. This means that the daily data needed to calculate the pivots for the new trading day must be downloaded first, before the indicator can use it.

              You have two options to achieve this:

              -> Open the Historical Data Manager -> Download, then select the instruments on the left side and "Day" on the right side of the popup box and download.

              -> Alternatively open a daily chart for the instrument that you have applied the pivots indicator to. This will also trigger the download of daily data.

              You should only observe this problem, if the indicator is set to "DailyBars". If you set it ot "CalcFromIntradayData", no daily data is needed and the update of the indicator value will be immediate.

              Comment


                #8
                Originally posted by Harry View Post
                You should only observe this problem, if the indicator is set to "DailyBars". If you set it ot "CalcFromIntradayData", no daily data is needed and the update of the indicator value will be immediate.
                This is what confuses me, in my code I have this:

                PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData

                so it is calculating intra-day.. the reason it confuses me is that an NT Pivots Indicator placed on a chart works just fine, without any need for reload. But my indicator that call the pivots indicator needs a reload.

                In the market analyzer the code is running on 5 Minute data about 1000 bars.

                On my charts with the indicator they are not time based.. they are either Range or Tick.

                Does any of this matter?

                Comment


                  #9
                  Originally posted by NinjaCustomer View Post
                  This is what confuses me, in my code I have this:

                  PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData

                  so it is calculating intra-day.. the reason it confuses me is that an NT Pivots Indicator placed on a chart works just fine, without any need for reload. But my indicator that call the pivots indicator needs a reload.

                  In the market analyzer the code is running on 5 Minute data about 1000 bars.

                  On my charts with the indicator they are not time based.. they are either Range or Tick.

                  Does any of this matter?
                  I think that you also need to reload the NinjaTrader pivots indicator. It does not reload new daily data, once it is setup on the chart. Therefore you need to save daily data to the historical data base and then refresh the indicator via F5.

                  Comment


                    #10
                    Originally posted by Harry View Post
                    I think that you also need to reload the NinjaTrader pivots indicator. It does not reload new daily data, once it is setup on the chart. Therefore you need to save daily data to the historical data base and then refresh the indicator via F5.
                    ah ok, maybe I was misremembering that NT Pivots didn't need a refresh. Then that explains everything. I just thought there was a disconnect between NT Pivots and my indicator that calls NT Pivots behaviour.

                    Thanks for the help

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by DanielSanMartin, Yesterday, 02:37 PM
                    2 responses
                    13 views
                    0 likes
                    Last Post DanielSanMartin  
                    Started by DJ888, 04-16-2024, 06:09 PM
                    4 responses
                    12 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by terofs, Today, 04:18 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by nandhumca, Today, 03:41 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post nandhumca  
                    Started by The_Sec, Today, 03:37 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post The_Sec
                    by The_Sec
                     
                    Working...
                    X