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

Tracking aggressive orders (above the ask and below the bid)

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

    #16
    Originally posted by NinjaTrader_ChelseaB View Post
    Hello WalterSkinner,

    Using GetCurrentAsk() vs capturing every ask market update depends on the needs of the script.

    If you need a snapshot of the current ask from time to time, use GetCurrentAsk().

    If you are collecting / aggregating ask updates or reacting to changes in the ask, use OnMarketData().
    Can you help me with a strange error?

    In post #11 I quote myself and mention a strange error that was happening the other day.

    I think there is still something strange going on with it because I just re-downloaded and re-imported the deleted files that were causing an issue. All of the problematic files were duplicates (renamed) of the example time & sales code that uses level 2 data (second link in post 4).

    I noticed that my code was not printing above-ask/below-bid trades that were showing up in the T&S window. I figured this is why the user had asked Kate what they did, and is why Kate produced the second example code that included level 2 data. When I re-imported this code I noticed that the name is one of the names I was using to try to resolve the error "aDidThisRename613pm"

    The screenshot I'm attaching is what came up when I was done importing the code, I didn't change anything after importing.

    Earlier today I reinstalled using https://ninjatrader.com/PlatformDirect to try to get ahead of this issue, in the event that it would have anything to do with the issue.

    Any idea what I should do? Rename the documents folder and reinstall again?
    Attached Files

    Comment


      #17
      Hello WalterSkinner,

      The screenshot does not show any errors.

      Do you have a full error message you would like assistance with?

      If there are duplicate classnames (or property names) remove the duplicates.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        In the mean time rather than getting bogged down by technical issues I've noticed that BuySellPressure looks like it could be slightly modified to give what I'm looking for so I'm switching gears to that for now.

        Edit:
        This is really interesting. If you modify that code so that it's looking for trades > or < (rather than >= or <=) it does what the code I wrote did where it didn't recognize above-ask or below-bid trades. This must mean that we have to use the more complex level 2 data to do this.
        Last edited by WalterSkinner; 07-26-2021, 11:19 AM.

        Comment


          #19
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello WalterSkinner,

          The screenshot does not show any errors.

          Do you have a full error message you would like assistance with?

          If there are duplicate classnames (or property names) remove the duplicates.
          I apologize for using the word "error" in a general sense.

          I looked back through the text I used to describe the "issue" I'm not sure I could do a better job of being detailed.

          To be less detailed: the imported code had modifications that should not be there. The screenshot has red arrows pointing to what I'm talking about.

          Sorry if I'm using imprecise language to describe these things I have a background in finance not computer science.

          Comment


            #20
            Hello WalterSkinner,

            Is there a specific condition that is not evaluating as true?

            Print the values in the condition with labels to understand why the condition is true or false.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello WalterSkinner,

              Is there a specific condition that is not evaluating as true?

              Print the values in the condition with labels to understand why the condition is true or false.
              https://ninjatrader.com/support/foru...121#post791121

              Rather than refer you to posts in the thread maybe if I copy and paste the posts I referred to within this post, the issue will make more sense.



              Originally posted by WalterSkinner View Post

              Can you help me with a strange error?

              In post #11 I quote myself and mention a strange error that was happening the other day.

              ...

              The screenshot I'm attaching is what came up when I was done importing the code, I didn't change anything after importing.

              Earlier today I reinstalled using https://ninjatrader.com/PlatformDirect to try to get ahead of this issue, in the event that it would have anything to do with the issue.

              Any idea what I should do? Rename the documents folder and reinstall again?
              In case you missed this I was referring to an issue described in post #11. I'll copy and paste it below to make sure there is no misunderstanding:

              Originally posted by WalterSkinner View Post

              The other night I ran into an issue duplicating the TnS example script from this thread. The editor would allow me to right click (in the editor) > save as > rename > compile but the new files stopped appearing when I right click (in chart) > indicators. Was very confused and walked away for a bit.

              There was a plot from that code called "Example Indicator" and once I removed each file that I duplicated the other night that didn't show up when trying to add to a chart, this issue was resolved. So fortunately it is unrelated to the code I'm working with now.
              Post #11 quotes this:
              I'm trying to make sure this code has no errors before adding the bid/ask data.

              The output window shows this error: "Indicator 'Examples Indicator': Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name"

              Which strikes me as odd since I'm not of an indi by that name. The only file in Documents\NinjaTrader 8\bin\Custom\Indicators that starts with the letter "E" is "ExampleTnSPrintsAboveAskBelowBid" and is not applied to any chart. In fact, no indicator is applied to any chart.

              I think this might be a thing to reach out to tech support for?

              I was hoping to figure out which property the auto-generated comment is referring to (the one about cumulative values which I think will apply to what I'm working on here), but first I feel like I've got to get to the bottom of this mystery indicator.

              Comment


                #22
                Hello WalterSkinner,

                I was under the impression you had removed the Examples Indicator.
                Code:
                There was a plot from that code called "Example Indicator" and once I removed each file that I duplicated the other night that didn't show up when trying to add to a chart, this issue was resolved. So fortunately it is unrelated to the code I'm working with now.
                So the error you are still working on is in the Examples Indicator and this was not resolved as you had stated:
                The output window shows this error: "Indicator 'Examples Indicator': Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name"

                Do you have the Examples Indicator code open? What is the code in OnStateChange()?
                Try and find the line causing the error by adding prints before each line.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello WalterSkinner,

                  I was under the impression you had removed the Examples Indicator.
                  Code:
                  There was a plot from that code called "Example Indicator" and once I removed each file that I duplicated the other night that didn't show up when trying to add to a chart, this issue was resolved. So fortunately it is unrelated to the code I'm working with now.
                  So the error you are still working on is in the Examples Indicator and this was not resolved as you had stated:
                  The output window shows this error: "Indicator 'Examples Indicator': Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name"

                  Do you have the Examples Indicator code open? What is the code in OnStateChange()?
                  Try and find the line causing the error by adding prints before each line.
                  Here's a summary in chronological order:
                  - Downloaded the TnS example code (the other day)
                  - That same day I renamed the indicator so I could mess with it
                  - I noticed that the most recent time I did this seemed to not work. So I tried again, and again. I didn't see the renamed duplicates on the right panel in the explorer (in the editor)
                  - I started putting the time of day at the end of the name so I could track which ones were visible and which were not
                  - At this point no new code (even though it would compile) would show up when I tried to add indicators
                  - A couple of days pass and I come back to the computer with the issue
                  - Tried to run totally unrelated code and got the error you quoted where it thought there was a plot called "Example Indicator".
                  - Removed every indicator and still got this message. I have a screen recording of this, because I suspected when I described it nobody would believe me.
                  - Figured that the mystery behavior was related to the mystery behavior from the other night that I described again in this list, so I removed every single file that was visible that was related to the TnS code as well as that code itself.
                  - Today I realized that (based on what I discovered by changing "<=" and ">=" to "=" from the BuySellPressure indicator (default indicator)) I had no choice but to try to use the level 2 data to get above-ask and below-bid pritns
                  - Because I need to use L2 now, I was forced to redownload the TnS code.
                  - After having removed all original TnS code as well as having removed all duplicates (to get rid of the error (or issue if you prefer) ), when I re-downloaded and re-imported the TnS code you see what is in the screenshot with the arrows showing the incorrect name. Must be stuck somewhere in the cache or something (not that I even know what that means), and reinstalling as I mentioned I had done this morning after removing the TnS code and its dupes did not prevent this bizarre behavior.

                  Screen recording: https://imgur.com/Q1UMdry
                  Last edited by WalterSkinner; 07-26-2021, 12:47 PM.

                  Comment


                    #24
                    Hello WalterSkinner,

                    In as few words as possible. What is the exact issue you need help with right now?

                    Do you need help with the error "Indicator 'Examples Indicator': Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name"?

                    If so, open the file with the Name property set to 'Examples Indicator'. Copy and paste the code from OnStateChange().
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello WalterSkinner,

                      In as few words as possible. What is the exact issue you need help with right now?

                      Do you need help with the error "Indicator 'Examples Indicator': Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name"?

                      If so, open the file with the Name property set to 'Examples Indicator'. Copy and paste the code from OnStateChange().
                      I've accepted the mystery I've just been doing my best to communicate the mystery to you.

                      Since you asked me to define the issue in the fewest words possible: "I would like to put an end to the bizarre behavior that includes but is potentially not limited to: an error from an indicator that was not applied to the chart, and opening a freshly imported indicator and having the indicator name change from what is in the source code to a previously-deleted name."

                      It's okay if there's nothing that can be done. These behaviors both happened today, as recently as about 2 hours ago when I took that screenshot. Neither behavior is occurring right now and I doubt you will be able to recreate it, which is why I was sure to document the issues when they occurred.

                      I've had mystery issues like this before which is why I have my important files backed up and am ready to reinstall NT regularly.

                      The reason I have taken the time to painstakingly document, type, retype and rephrase was in the hopes that this bizarre behavior had a remedy.

                      Again, I've accepted it by now so feel free to let it go as well.

                      Comment


                        #26
                        Hello WalterSkinner,

                        The error is an OnStateChange error. OnStateChange is run every time the Indicators or Strategies window is opened. State.SetDefaults is called for every script to get the default values that are being populated in the Indicators window.

                        The indicator does not have to be added to the chart. The indicator only needs to have an error in OnStateChange and the Indicators window be opened.
                        This is expected behavior for errors in OnStateChange().

                        What can be done, is the indicator code can opened, and whatever line of code causing the issue is removed, or relocated to the proper place. Or the indicator can be removed.
                        Last edited by NinjaTrader_ChelseaB; 07-26-2021, 01:38 PM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello WalterSkinner,

                          The error is an OnStateChange error. OnStateChange is run every time the Indicators or Strategies window is opened. State.SetDefaults is called for every script to get the default values that are being populated in the Indicators window.

                          The indicator does not have to be added to the chart. The indicator only needs to have an error in OnStateChange and the Indicators window be opened.
                          This is expected behavior for errors in OnStateChange().

                          What can be done, is the indicator code can opened, and whatever line of code causing the issue is removed, or relocated to the proper place. Or the indicator can be removed.
                          Thank you!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by GwFutures1988, Today, 02:48 PM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by ScottWalsh, 04-16-2024, 04:29 PM
                          6 responses
                          32 views
                          0 likes
                          Last Post ScottWalsh  
                          Started by frankthearm, Today, 09:08 AM
                          10 responses
                          36 views
                          0 likes
                          Last Post frankthearm  
                          Started by mmenigma, Today, 02:22 PM
                          1 response
                          4 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by NRITV, Today, 01:15 PM
                          2 responses
                          10 views
                          0 likes
                          Last Post NRITV
                          by NRITV
                           
                          Working...
                          X