• 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

Calling the results from another indicator

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

    Calling the results from another indicator

    Hi,

    I'm attempting to call the SwingHigh and the SwingLow from the Swing indicator to use within my indicator.

    double SwHigh = Swing().SwingHigh[0];
    double SwLow = Swing().SwingLow[0];

    But I'm getting the following error code "No overload for method "Swing" takes "0" arguments"

    Can't figure it out where I'm wrong. Thanks in advance

    #2
    Originally posted by 2Look4me View Post
    Hi,

    I'm attempting to call the SwingHigh and the SwingLow from the Swing indicator to use within my indicator.

    double SwHigh = Swing().SwingHigh[0];
    double SwLow = Swing().SwingLow[0];

    But I'm getting the following error code "No overload for method "Swing" takes "0" arguments"

    Can't figure it out where I'm wrong. Thanks in advance
    Try

    Code:
    double SwHigh  =   Swing(period).SwingHigh[0];
    double SwLow   =   Swing(period).SwingLow[0];
    where period is an integer.

    Comment


      #3
      Thanks Harry. Inserting an integer will not give a compilation error. But what is the premise behind it and what would the integer represent?

      Comment


        #4
        Hello 2Look4me,

        The overloads for the swing indicator are the following:

        Swing(int strength).
        Swing(IDataSeries input, int strength)

        The strength refers to the number of required bars to the left and right of the swing point.

        This is outlined in the help guide for the Swing indicator.
        http://www.ninjatrader.com/support/h.../nt7/swing.htm

        (You can also read this description if you add an instance of the Swing indicator to a chart and look at the parameters)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Inserting an integer will not give a compilation error. But what is the premise behind it and what would the integer represent?
          This is from Ninja Help on Swing:

          The Swing indicator will plot lines that represent the swing points based on the strength (number of bars to the left and right of the swing point) parameter provided. You can access methods within this indicator to determine the number of bars ago a swing point occured or the current swing value.
          Effectively, this is the number of bars you have to wait before the system marks that bar as a pivot.

          Comment


            #6
            If SwingHigh[0] is the last SwingHigh. Is it the same case for previous SwingHigh's, i.e. SwingHigh[1], SwingHigh[2]?

            Am I wrong to assume that, since it isn't working out for me or am I doing something wrong?

            Comment


              #7
              The problem with any swing indicator is that it cannot determine, whether the current bar will become a swing high, a swing low or nothing. You have to wait for N bars, if N is the swing strength, before you can check for a swing high or low.

              Therefore all swing indicators need to repaint. If you call a value for the current bar, you may actually obtain the value for the prior swing high or low, if it is still active, Then a few bars later, that value will be removed by the indicator and replaced with another one that is shown on the chart,

              If you want to avoid that situation, you should only access SwingHigh and SwingLow N bars ago, where N is the swing strength. Those values are final and will not be modified any more.

              Comment


                #8
                As always, that's great advice from Harry.

                As Harry points out, you have to wait N bars to be sure the latest line won't repaint.

                I'll just make a specific point to answer one of your questions:

                If SwingHigh[0] is the last SwingHigh. Is it the same case for previous SwingHigh's, i.e. SwingHigh[1], SwingHigh[2]?
                SwingHigh[0] is necessarily the level is the latest calculated SwingHigh (repainted or not) at BarsAgo = 0.
                SwingHigh[1] is the level is the SwingHigh (repainted or not) effective at BarsAgo = 1.

                ...

                SwingHigh[m] is the level is the SwingHigh (repainted or not) effective at BarsAgo = m.

                If you put the following code into an indicator:

                if (CurrentBar < Count - 2)
                return;

                for (int i = 0; i <= 19; i++)
                {
                DrawArrowUp(i.ToString(), true, i, Swing(High, SwingStrength).SwingHigh[i], Color.Blue);
                }


                you'll see arrows being drawn at the SwingHighs (repainted or not) up to 20 bars ago, and this illustrates the points I've been making.

                So 'SwingHigh[1]' is not necessarily the level of the second SwingHigh back, for example.
                Last edited by arbuthnot; 03-25-2015, 02:59 PM.

                Comment


                  #9
                  Thanks arbutnot and Harry for the detailed explanation on how the SwingHigh and SwingLow are calculated and displayed. It was really helpful.

                  In a separate thread but I believe related to my same question :
                  http://www.ninjatrader.com/support/f...ighlight=swing

                  NinjaTrader_Cal replied:
                  What you are getting are the calculated results of the swing at these points but not the plot of the swing.

                  Each bar the swing will re-calculate swing levels, but the rest of the internal code is determining whether or not to update the plot value.

                  If this is what you are looking for you would need to save the swing indicator as a new indicator that you can custom code.

                  You would then go to the properties section of the new indicator and change the SwingHighPlot and SwingLowPlot and change these to Public DataSeries rather then the current Private.
                  Will the change from Private to Public DataSeries make prior SwingHigh plots calculations available? I tried that change but didn't notice anything different. What will the change exactly do?

                  Comment


                    #10
                    Originally posted by 2Look4me View Post
                    Thanks arbutnot and Harry for the detailed explanation on how the SwingHigh and SwingLow are calculated and displayed. It was really helpful.

                    In a separate thread but I believe related to my same question :
                    http://www.ninjatrader.com/support/f...ighlight=swing

                    NinjaTrader_Cal replied:
                    Will the change from Private to Public DataSeries make prior SwingHigh plots calculations available? I tried that change but didn't notice anything different. What will the change exactly do?
                    Hi - I think there is a technique to detect the nth swing high/low back. It's based on the Most Recent Occurrence (MRO) method.

                    I haven't tested this but something like this should work:

                    int barsAgo = MRO(delegate {return Swing(High, SwingStrength).SwingHigh[0] != Swing(High, SwingStrength).SwingHigh[1];}, 1, k);

                    (k = the period you want to do this check over, '1' is looking for the 1st change.)

                    then:

                    Swing(High, SwingStrength).SwingHigh[barsAgo + 1];

                    will give you the level of the second swing going back.

                    Please look up MRO in Help and elsewhere to fully understand it first. It's a very powerful method.

                    Comment


                      #11
                      arbuthnot, thanks for pointing out "MRO", a very helpful function. I tested your code
                      Code:
                      int barsAgo = MRO(delegate {return Swing(High, SwingStrength).SwingHigh[0] != Swing(High, SwingStrength).SwingHigh[1];}, 1, k);
                      and as I tried different "k's", the results were no different and it didn't seem to be determining the previous Swing levels

                      Also, when inserting
                      Code:
                      Swing(High, SwingStrength).SwingHigh[barsAgo + 1];
                      I was getting a compile error: "Only assignment, call,increment, decrement, and new object expressions can be used as a statement"

                      Comment


                        #12
                        I was able to resolve the issues with prior Swing High/Low's calculations, so thanks to all for the input.

                        The remaining question that I have is if my main indicator is set for OnBarClose = false and with it I'm calling the Swing indicator which I it need to be OnBarClose = true; how can this be accomplished?

                        Comment


                          #13
                          Originally posted by 2Look4me View Post
                          I was able to resolve the issues with prior Swing High/Low's calculations, so thanks to all for the input.

                          The remaining question that I have is if my main indicator is set for OnBarClose = false and with it I'm calling the Swing indicator which I it need to be OnBarClose = true; how can this be accomplished?
                          Glad you've got this sorted.

                          You'll have worked out that if you set:

                          int barsAgo = MRO(delegate {return Swing(High, SwingStrength).SwingHigh[0] != Swing(High, SwingStrength).SwingHigh[1];}, 3, k);

                          then:

                          Swing(High, SwingStrength).SwingHigh[barsAgo + 1];

                          will give you the third swing high.

                          As for your CoBC=false question, I'd rather not guess on that. May I suggest if you don't get a response to this in this thread, start a new one and the brilliant Ninja staff will answer you within a short time.

                          Comment


                            #14
                            arbuthnot, thanks again for the reply. Will do so.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by henit, 08-24-2019, 09:10 AM
                            3 responses
                            40 views
                            0 likes
                            Last Post guidoisot  
                            Started by zoreanuv, Today, 01:14 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post zoreanuv  
                            Started by profitabletrader306, Today, 12:00 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post profitabletrader306  
                            Started by marcelodelta, Yesterday, 08:28 PM
                            2 responses
                            11 views
                            0 likes
                            Last Post marcelodelta  
                            Started by junkone, Yesterday, 09:06 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Marco  
                            Working...
                            X