• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SampleMultiColoredPlot

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

    SampleMultiColoredPlot

    I've modified NT's SampleMultiColoredPlot to plot 3 colors of the LinReg indicator.
    My issue is that I can't seem to get a neutral (Flat) color to show.
    I would think that there would be a value to determine when to show neutral (How flat is flat)

    Thank you in advance for your input...

    #2
    Hello Randwulf,
    Thanks for posting today.

    When you are referring to a flat color, I am confused on what you are attempting to accomplish.

    The slope of the graph? A flat position?

    How are you determining if a flat condition exists?

    Please clarify and I will be able to better assist you.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Thx 4 the reply Alex.
      In the sample file, it plots an SMA which is colored RED when the slope is up, Green when slope is down & Yellow when neutral.
      I simply substituted LinReg (Linear Regression) for the SMA.
      It plots it correctly, green when sloping up and red when sloping down just fine but, there is no yellow plotted when the line is neutral (flat) like the coding indicates.

      Comment


        #4
        Originally posted by Randwulf View Post
        Thx 4 the reply Alex.
        In the sample file, it plots an SMA which is colored RED when the slope is up, Green when slope is down & Yellow when neutral.
        I simply substituted LinReg (Linear Regression) for the SMA.
        It plots it correctly, green when sloping up and red when sloping down just fine but, there is no yellow plotted when the line is neutral (flat) like the coding indicates.
        May I just point out that LinReg, being a double (i.e. decimal), will never be exactly flat, i.e.

        LinReg (14)[0] - LinReg (14)[1] == 0

        will never happen, but you could put something like:

        if Math.Abs(LinReg (14)[0] - LinReg (14)[1] ) < .001 // or any figure you like

        {action}

        Comment


          #5
          Thx 4 the reply arbuthnot...

          Yeah, I saw the "Rising" & "Falling" and realized that it would pretty much never show "Neutral".
          It's just that NT used SMA in the code as an example and it would have the same issue.
          I changed the Rising & Falling lines of code to look for slope above and below a threshold and it's working fine.

          ex: if (Slope(LinReg(Period), 1, 0) > 0.0099).... for long

          Thanks again though for taking the time to respond.
          That's what community is all about.
          I hope that this may be helpful to others...

          Comment


            #6
            Hello Randwulf,
            Thanks for the reply.

            Do you see in the plot situations where the indicator is flat? It may not occur very frequently when using the LinReg indicator.

            If you adapted the code from the SampleMultiColoredPlot it uses the IsFalling() and IsRising() methods and then an else statement to plot the flat/neutral condition.

            If the LinReg is never not rising or falling you will never have a neutral flat condition.

            What is the condition statement you use when looking for neutral flat amounts?

            I look forward to your reply.
            Alex G.NinjaTrader Customer Service

            Comment


              #7
              Hello,
              Thanks for the update.

              Glad to see that this was resolved.

              Please let us know if we may be of further assistance for anything NinjaTrader.
              Alex G.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by Randwulf View Post
                Thx 4 the reply Alex.
                In the sample file, it plots an SMA which is colored RED when the slope is up, Green when slope is down & Yellow when neutral.
                I simply substituted LinReg (Linear Regression) for the SMA.
                It plots it correctly, green when sloping up and red when sloping down just fine but, there is no yellow plotted when the line is neutral (flat) like the coding indicates.
                The only thing about my 'Math.Abs' approach is that the one line of code can be used for both directions.

                The LinReg indicator is quite jagged which doesn't help when looking at its slope, but I've found that HMA is very smooth and it runs very close to LinReg.

                The best question to ask, as you're effectively doing, is: when does price regress towards / away from the mean?

                As a matter of interest, could you tell me where you found SampleMultiColoredPlot as it's not in my NT7 (latest version).

                Thanks.
                Last edited by arbuthnot; 05-08-2015, 09:11 AM.

                Comment


                  #9
                  arbuthnot,

                  The Math.Abs would take care of positive or negative solution but I need to differentiate between the two.
                  The LinReg being jaggy is OK for me as I'm only looking whether or not price is mostly on one side or the other.

                  The sample can be found here:
                  http://www.ninjatrader.com/support/f...ead.php?t=3227

                  Comment


                    #10
                    Originally posted by Randwulf View Post
                    arbuthnot,

                    The Math.Abs would take care of positive or negative solution but I need to differentiate between the two.
                    The LinReg being jaggy is OK for me as I'm only looking whether or not price is mostly on one side or the other.

                    The sample can be found here:
                    http://www.ninjatrader.com/support/f...ead.php?t=3227
                    Thanks for the link.

                    The Math.Abs would take care of positive or negative solution but I need to differentiate between the two.
                    You're right of course. I thought of that after I'd posted!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by frankduc, Today, 07:26 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post frankduc  
                    Started by chnh1, Yesterday, 11:51 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Started by Jasper99, Yesterday, 10:29 PM
                    1 response
                    28 views
                    0 likes
                    Last Post NinjaTrader_ChrisSch  
                    Started by Jasper99, Yesterday, 09:50 PM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_ChrisSch  
                    Started by StevenNelson, Yesterday, 05:57 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Marco  
                    Working...
                    X