How to code to identify swings?

 

Hello everyone

Is there anyone that can direct me pages where I can read up on how to code to identify swings? It's easy for me to identify them, but the method I'm using visually is not consistent enough to translate it to the PC. I have broken my brain these past couple of days trying to figure something out and started to search online for methods, but I only get ready made stuff. I've tried reverse engineering a couple to understand the reasoning behind how it works, but it is a real struggle (still a newbie at coding). Any help will be appreciated, whether through explaining or directing me to places where I can learn. I'll continue searching in the meantime.

Thanks

 
Until you can state, in concrete terms, what you mean by swings, it can not be coded.
 

I don't really understand what you mean by that. As in what defines a swing? I normally just look at a chart and when I see this (as in the picture), that's how I perceive swings. I've tried using different MAs, crosses etc, but I still cannot really find something that can give me a sure way of telling the PC what a swing is. Sometimes a swing is a couple of candles, like the T1 and T2 arcs, other times it's almost 10 with weird dips and stuff in between, like the B1 - B3 arcs. When using MAs as a guide, it'll pick up the dip in the middle as a swing too



 
PLZFrosty:

I don't really understand what you mean by that. As in what defines a swing? I normally just look at a chart and when I see this (as in the picture), that's how I perceive swings. I've tried using different MAs, crosses etc, but I still cannot really find something that can give me a sure way of telling the PC what a swing is. Sometimes a swing is a couple of candles, like the T1 and T2 arcs, other times it's almost 10 with weird dips and stuff in between, like the B1 - B3 arcs. When using MAs as a guide, it'll pick up the dip in the middle as a swing too



Thats because you draw the swing in this picture only after knowing the price action took a swing. 
 
Show me an old chart and i show you how to trade it. you cant identify a swing previously
 
The process is the following: We are on the last candle currently. I want to know the x amount of swings that preceded from where we are now and store their info (level, time, whatever) into an array, struct or something.
 
PLZFrosty:I don't really understand what you mean by that. As in what defines a swing?

Exactly.

B1

In your B1, I see two swing highs and two swing lows. Whereas you only indicate one low. How do you define your swings to differentiate from the four I see?

 
William Roeder:

Exactly.

In your B1, I see two swing highs and two swing lows. Whereas you only indicate one low. How do you define your swings to differentiate from the four I see?

That's the same problem I had with using the EA method (5 SMA C 0 was the best one I could figure out so far). That whole B1 section is a swing low, hence the yellow arc. I use the 5 SMA  to see them easier and filter it from there, so wherever it makes a turning point i look at 2 candles' values (SMA) to the left and right and if, for example, the 2 values to the left are descending to the middle and ascending from the middle to the right it is a swing low. The problem is that when I look at the price movement on that chart (5M) that whole section is a swing low (yellow arc).


I think I have found a way to identify it better now. I never knew that you can shift an indicator to the left. While I was playing around I saw that the 12 SMA was more or less making the curve that I wanted, i.e representing the yellow arcs more. So I then shifted the indicator to the left by 3 (Shift = -3) and it gave me this

Now I'm probably not going to use the -3 shift, but it makes it easier to spot what I want for now. I'm going to give it a better look at. Hopefully this is what I needed to better identify what I'm looking for. I also recently stumbled upon the iHighest/iLowest functions while trying to learn from someone else's code (LastManStanding of Jay Davis). Going to give those functions a try too. If you have any better suggestions/sources please share. I'll definitely read it up!

 
Try using ZigZag if you just want to count the preceding "swings"
 
iRick:
Try using ZigZag if you just want to count the preceding "swings"

Oh my soul I feel so dumb! Thanks a million! It was exactly what I was looking for!

 
There's an article related to this, it's called The Power of Zigzag or so.