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

Very bizzare indicator behavior - need help

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

    Very bizzare indicator behavior - need help

    Hi,

    I have this indicator, a stochastics kind, which acts pretty odd.

    It plots (sometimes) for the period of 7 and higher, but only when the charts are static (no streaming data), but it does not plot at all (you get a blank region) when the data is streaming (so no use for real time trading).

    Well, I am clueless as to what could be wrong with it. I got it from this forum, if I am not mistaken. I would appreciate your help. Thanks.

    The code is attached.
    Attached Files

    #2
    electron,

    Thank you for your post and welcome to our forums!

    Was this an indicator you were working on? Or have you installed it from another author's work?

    When experiencing issues connecting in real time, do you get any errors on the Log tab of the Control Center listed in yellow? If so, what do these errors report?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      electron,

      Thank you for your post and welcome to our forums!

      Was this an indicator you were working on? Or have you installed it from another author's work?

      When experiencing issues connecting in real time, do you get any errors on the Log tab of the Control Center listed in yellow? If so, what do these errors report?
      Hi Matthew,

      Thanks for your prompt reply.

      I was using the code from another author. I wanted to add some twist to this indicator, but I found out that it was not working properly as it was.

      Yes, I do get some error in the log on connecting when the plot disappears. Here is what the log says: "Error on setting indicator plot for indicator 'StochasticsPreferred'. Value outside of valid range."

      Any advice would be appreciated.

      Thanks again.

      Comment


        #4
        Hello,

        the logic is correct, however you're likely running into an issue explained in the following forum post:
        http://www.ninjatrader.com/support/forum/showthread.php?t=3170

        Please try adding the following snippet to the beginning of your code in OnBarUpdate()

        Code:
        if (Current Bar < 1)
        return;
        You need to ensure you have enough bars on the chart to calculate correctly.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Matthew View Post
          Hello,

          the logic is correct, however you're likely running into an issue explained in the following forum post:
          http://www.ninjatrader.com/support/forum/showthread.php?t=3170

          Please try adding the following snippet to the beginning of your code in OnBarUpdate()

          Code:
           
          if (Current Bar < 1)
          return;
          You need to ensure you have enough bars on the chart to calculate correctly.
          I had tried to do something like that before, but with no good outcome. I did it again following your advice, but the result is a blank plot again. The log gives the same error, too.

          Thanks for trying to help, though. Any other ideas?

          Comment


            #6
            electron,

            If that did not improve, I"d suggest commenting out various segments of the code to see if you can locate where these errors are coming from. There is a comment already in your code about 'Does not plot!' so i'm not sure if this a known issue. You might want to see if you can check with the original author to see if this issue has already been resolved.

            Please see the following Forum Post on Debugging your NinjaScipt code for more tips:

            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Matthew View Post
              electron,

              If that did not improve, I"d suggest commenting out various segments of the code to see if you can locate where these errors are coming from. There is a comment already in your code about 'Does not plot!' so i'm not sure if this a known issue. You might want to see if you can check with the original author to see if this issue has already been resolved.

              Please see the following Forum Post on Debugging your NinjaScipt code for more tips:

              http://www.ninjatrader.com/support/f...ead.php?t=3418
              The "Does not plot!" comment was added by me after compiling and seeing the results. Well, I will try to do a more thorough debugging.

              Comment


                #8
                Originally posted by electron View Post
                The "Does not plot!" comment was added by me after compiling and seeing the results. Well, I will try to do a more thorough debugging.
                This line is most likely your problem. You are not checking for a division by zero. It need not be exactly zero; even if it is just a very small value, rounding errors can quickly send the result out of bounds.

                Code:
                 
                raw.Set(100*((Close[0] - MIN(Low, period)[0]) / (MAX(High, period)[0] - MIN(Low, period)[0])));

                Comment


                  #9
                  Originally posted by koganam View Post
                  This line is most likely your problem. You are not checking for a division by zero. It need not be exactly zero; even if it is just a very small value, rounding errors can quickly send the result out of bounds.

                  Code:
                   
                  raw.Set(100*((Close[0] - MIN(Low, period)[0]) / (MAX(High, period)[0] - MIN(Low, period)[0])));
                  Hi,

                  Thanks for your advice. Yes, you may be right, but could you give me a piece of code that handles this problem correctly, if that's not too much to ask.

                  Thanks again.

                  Comment


                    #10
                    MACD disappears

                    when a drag a MACD over a stochastic sub graph,it stay for ahile then vanishes

                    Comment


                      #11
                      Originally posted by electron View Post
                      Hi,

                      Thanks for your advice. Yes, you may be right, but could you give me a piece of code that handles this problem correctly, if that's not too much to ask.

                      Thanks again.
                      As an example you can check into our default Stochastics indicator code and how it would tackle this area successfully.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by laredo78676 View Post
                        when a drag a MACD over a stochastic sub graph,it stay for ahile then vanishes
                        What scale are you then using for both? Each on their own? If you try putting them on the same scale that will create issues as the total scaling range seen for the range bound Stochastic va non range bound MACD will be very different.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          macd

                          Can I adjust the scaling?

                          Comment


                            #14
                            You could put both indicators on one panel, but different scales so this setup could be visualized better - please see 'Understanding Panel' from this helpguide link, which would include a video as well -

                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Mizzouman1, Today, 07:35 AM
                            3 responses
                            17 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by RubenCazorla, Today, 09:07 AM
                            2 responses
                            13 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by i019945nj, 12-14-2023, 06:41 AM
                            7 responses
                            82 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by timmbbo, 07-05-2023, 10:21 PM
                            4 responses
                            158 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by tkaboris, Today, 08:01 AM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X