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

Problematic Indicator

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

    Problematic Indicator

    I have attached extracted relevant portions of a problematic indicator that I converted from NT7 to NT8 ... I call the indicator "Problematic". The indicator successfully compiles, but it does not plot the Drawing objects (Lines, Rays, and Texts) when I load it onto a chart. Why are the Drawing objects not plotting or showing up ?

    Problematic.cs

    #2
    make sure you have enough bars first for example you want to draw from 10 bar back then making sure the chart has 10 bars first

    Comment


      #3
      The file you provided doesn't compile and is missing a bunch of code, so it's not of much use. Check your ninjascript output log and the log files as a starter.

      Comment


        #4
        Originally posted by nkhoi View Post
        make sure you have enough bars first for example you want to draw from 10 bar back then making sure the chart has 10 bars first
        Yes, I have tried "if(CurrentBar < 10) return;" but it didn't work.

        Comment


          #5
          Originally posted by NicholasJoannette View Post
          The file you provided doesn't compile and is missing a bunch of code, so it's not of much use. Check your ninjascript output log and the log files as a starter.
          The provided file contains ONLY extracted relevant portions of the indicator ... it is not expected to compile. It is the Draw.Line, Draw.Ray and Draw.Text that seem to have issues.

          Comment


            #6
            Originally posted by omololu View Post
            Yes, I have tried "if(CurrentBar < 10) return;" but it didn't work.
            That doesn't do what he's suggesting to do. Using
            Code:
            if (CurrentBar < 10) return;
            will just return if the current bar being calculated in OnBarUpdate is within the 10 most recent bars. What nkhoi was suggesting was that you check there are sufficient bars on the chart. Something like
            Code:
            ChartBars.Bars.Count > 10
            NT8 is not like NT7 - if you didn't know about this basic difference above, then it's likely that the issue is originating in the other parts of the code that you deemed irrelevant.

            Originally posted by omololu View Post
            The provided file contains ONLY extracted relevant portions of the indicator ... it is not expected to compile. It is the Draw.Line, Draw.Ray and Draw.Text that seem to have issues.
            These Draw functions on their own work well. There is likely an issue with the arguments in your calls. If you converted from NT7 to NT8, it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments. Just a guess though - good luck.

            Code:
              
            Draw.Line(this,"BD"+Var, CurrentBar - PeakIndex[a], Peak[a], CurrentBar - TroughIndex[DnCount], Trough[DnCount], BullishSetup);

            Comment


              #7
              Originally posted by NicholasJoannette View Post

              That doesn't do what he's suggesting to do. Using
              Code:
              if (CurrentBar < 10) return;
              will just return if the current bar being calculated in OnBarUpdate is within the 10 most recent bars. What nkhoi was suggesting was that you check there are sufficient bars on the chart. Something like
              Code:
              ChartBars.Bars.Count > 10
              NT8 is not like NT7 - if you didn't know about this basic difference above, then it's likely that the issue is originating in the other parts of the code that you deemed irrelevant.



              These Draw functions on their own work well. There is likely an issue with the arguments in your calls. If you converted from NT7 to NT8, it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments. Just a guess though - good luck.

              Code:
              Draw.Line(this,"BD"+Var, CurrentBar - PeakIndex[a], Peak[a], CurrentBar - TroughIndex[DnCount], Trough[DnCount], BullishSetup);
              Thanks for your comments.

              So, how do I use "ChartBars.Bars.Count > 10" ?

              Comment


                #8
                Hi, thanks for posting.

                If you are getting a bars ago indexing error then there are not enough bars on the chart when the command is executed. I agree with Nicholas "it is likely a problem with the CurrentBar-PeakIndex[a] or CurrentBar-TroughIndex[DnCount] arguments" without the full code it's hard to tell. You can use Visual Studio to break when the exception occurs and that wil show you what line is causing the problem:


                Kind regards,
                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by alifarahani, Today, 09:40 AM
                3 responses
                15 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by RookieTrader, Today, 09:37 AM
                4 responses
                17 views
                0 likes
                Last Post RookieTrader  
                Started by PaulMohn, Today, 12:36 PM
                0 responses
                4 views
                0 likes
                Last Post PaulMohn  
                Started by love2code2trade, 04-17-2024, 01:45 PM
                4 responses
                39 views
                0 likes
                Last Post love2code2trade  
                Started by junkone, Today, 11:37 AM
                3 responses
                23 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X