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

Divergence Price Delta

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

    Divergence Price Delta

    Hello,

    I´m trying to create an indicator which would display marker when there is a divergence between price and delta (Close > Open && delta < 0 and vice versa). The marker should be displayed on a price chart.

    I used NT8 default indicator BuySellVolume as a start. Compiled successfully, but there is still some problem.

    Thank you for any help.
    Attached Files

    #2
    Hello emuns,

    Are you getting a run-time error message?

    If so, what is the error message?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      yes. It says:
      Indicator 'DivergencePriceDelta': Error on calling 'OnBarUpdate' method on bar 2: Index was outside the bounds of the array.

      Comment


        #4
        Hello emuns,

        An index error means an invalid index was used.

        I notice that all of the public series are returning Values[0].
        Was this a mistake?
        Were you intending to have these match the plots such as Values[1], Values[2], etc?

        Which line is causing the error?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          thank you for your answer… My first attempt was completely wrong. So I decided to start from zero. The other indicator which I created works much better with only exception. It should show marker above/below bar when condition is met. The marker is correctly displayed, but it is one bar late (I mean that it takes one more minute, on one minute chart, to display). I will explain it by an example: I have one minute chart. Marker should be above bar which closes at 9:00. When this bar closes there is no marker. When the next bar (9:01) closes, than the marker displays above the 9:00 bar.
          I´m unable to solve it. Could you help me please?
          Attached Files

          Comment


            #6
            Hello emuns,

            The indicator you have provided uses an index variable for the barAgo parameter for Draw.ArrowDown() and for the Close and Open values.

            This index can be a 1 or a 0. If you don't want the script checking 1 bar ago and drawing 1 bar ago, ensure this is always a 0.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,

              yes I know. But when I change it to zero, than the marker is displayed incorrectly. When 9:00 bar is the signal bar, than the marker should be above it. But it is displayed above bar 9:01...

              The reason why I used the index variable, is that without that, it shows incorrect results in real-time (historical results were OK). Maybe it is not correct way…?

              Comment


                #8
                Hello emuns,

                This is the logic of the script. If index is 1, then it compares the previous bars close to the previous bars open and draws an arrow on the previous bar. You will need to change the logic so that it is not checking the previous bars close and open and is instead checking the current bars close and open and then drawing on the current bar.

                You changed it to 0. You mean you are hard coding a 0 in all indexes and barsAgo values?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chelsea,

                  there is a problem that I´m comparing bars close to bars open with bars delta. So when I hard-coded 0 in all indexes and barsAgo values, than I got correct historical results, but real-time results are completely wrong. The marker is not one bar behind/forward, but it is completely wrong.

                  When I change only the Draw.ArrowDown values as follows:

                  Draw.ArrowDown(this, "MyStringTagDown" + CurrentBar, false, 0, High[0] + Vzdálenost * TickSize, DownMarker);

                  than the marker is only incorrectly placed. It should be above prior bar, but in global reflects the condition.
                  Last edited by emuns; 03-06-2019, 02:20 PM.

                  Comment


                    #10
                    Hello emuns,

                    Are you saying the value for iOrderFlowCumulativeDelta.DeltaClose[0] is incorrect?

                    What is the value of this?
                    What value are you expecting?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Chelsea,

                      when I replace index with zero (see indicator in attachment), than markers displayed on historical data are OK. But markers on real-time data are incorrect because indicator compares current bar with prior bars delta.
                      Attached Files

                      Comment


                        #12
                        Hello emuns,

                        To confirm, when the bar closes, iOrderFlowCumulativeDelta.DeltaClose[0] is the value for the bar previous and not the for the bar with the time stamp of that bar?

                        Are you comparing the time of the bar with the value with the indicator added directly to the chart?

                        How do you know its the previous bars value if you are not printing the time with the with print?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Chelsea, you are right!
                          So, now better, I hope (see attachment)...

                          It is evident that historical data are displayed almost correctly (there is discrepancy about 2 contracts). Real-time data are incorrect, because
                          iOrderFlowCumulativeDelta.DeltaClose[0] is the value for the bar previous (
                          and not for the bar with the time stamp of that bar).
                          Attached Files

                          Comment


                            #14
                            Hello emuns,

                            What are you saying I am right about?

                            What are you comparing?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Chelsea,

                              sorry… You wrote:
                              "How do you know its the previous bars value if you are not printing the time with the print?"
                              My reaction was: "you are right". And I added the indicator where is the print script complete (the time is printing too).


                              I´m comparing data in NinjaScript Output (source of the data is my indicator - see above) with the data which I can see directly on a chart (source of the data is OrderFlowCumulativeDelta). The data don´t correspond to each other!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by mgco4you, Today, 09:46 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post mgco4you  
                              Started by Rapine Heihei, Today, 08:19 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 08:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by f.saeidi, Today, 08:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 07:51 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Rapine Heihei  
                              Working...
                              X