Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing indicator

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

    Swing indicator

    Hello,

    Is there a way of catching via code the first yellow dot of the swing indicator?

    Basically when SwingLowBar or SwingHighBar start!

    Thanks.
    Alex


    #2
    Hello,

    SwingHighBar and SwingLowBar will return -1 when an occurrence has not been found within the lookback period.

    Once an occurrence has been found, it will return a value of 0 for that bar. So you can check for a value of 0 and your condition should be satisfied:

    Code:
    			if(Swing(5).SwingHighBar(barsAgo, instance, lookBackPeriod) == 0)
    			{
    				//doSomething;
    			}


    Please let me know if you have additional questions.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Would you please be so kind to explain exactly what the three variables (int barsAgo, int instance, int lookBackPeriod) do in the swing method?

      The documentation is not clear to me. I understand the "barsago"...

      When I try
      if
      (Swing(5).SwingLowBar(0, 1, 10) == 0)

      I get no signals. If I do
      if
      (Swing(5).SwingLowBar(0, 1, 10) > 0)

      I get a signal for each bar!

      High Bar
      Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
      Swing(IDataSeries input, int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)

      Low Bar
      Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod)
      Swing(IDataSeries input, int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod)


      Thanks!
      Tex
      Last edited by TexFly; 09-10-2012, 06:27 PM.

      Comment


        #4
        Sorry - the value that is being return will be equal to the swing strength, not 0 as I stated.

        If you're using a swing strength of 5, then you would want to check for a value of 5.

        Using an instance of 1, it will return the most current instance. Using 2 would give you the 2nd most recent instance.

        The lookback tells how many bars it will look back to check for an occurrence.

        You may want to visually draw the number being returned to visual how this will work

        Code:
        double hi = Swing(5).SwingHighBar(0, 1, 10);
        			
        DrawText("highbar" + CurrentBar, hi.ToString(), 0, Low[0], Color.Black);
        MatthewNinjaTrader Product Management

        Comment


          #5
          Thanks for the reply. I'm still missing something. All I'm trying yo do is catching the dot shown in the picture below. I want to add an arrow when the first orange signal shows.

          Thanks!
          Tex

          Last edited by TexFly; 09-13-2012, 03:18 AM.

          Comment


            #6
            The Swing indicator plot repaints, so it is expected that indicator values and plot values will different.

            The logic you're using to paint the DrawArrow in your indicator would not necessarily match the Swing indicator plot.
            MatthewNinjaTrader Product Management

            Comment


              #7
              How do I match it? ;-)

              How do I catch that first dot?

              Comment


                #8
                The Swing indicator was designed as a visual tool. Since this indicator repaints, it would be hard to match it completely.

                You may want to consider working with HighestBar() and LowestBar();

                Code:
                			int highestbar = HighestBar(High, 10);
                			int lowestbar = LowestBar(Low, 10);
                			
                			if(lowestbar == 0)
                			{
                		
                			DrawArrowUp("lowbar"+CurrentBar, false, lowestbar, Low[0], Color.Blue);
                			}
                			
                			if(highestbar == 0)
                			{
                			DrawArrowDown("highlow"+CurrentBar, false, highestbar, High[0], Color.Red);
                			}
                Please also see our sample on Referencing the Correct Bar for more information:

                MatthewNinjaTrader Product Management

                Comment


                  #9
                  sorry, i just new join the forum.
                  may i ask, where can i can the swing indicator for file ex.4 ?

                  Comment


                    #10
                    Hello,

                    Welcome to our forums!

                    I'm sorry, I'm afraid I do not know what file ex.4 is. Can you please elaborate?
                    MatthewNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    649 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    370 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    573 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    576 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X