# Now that we have a strategy that works we need to see how the stock has traded in the past to generate target prices and stop loss levels.

## Past Pivots Will Show us How a Stock Will Trade in the Future

It's a fact, if you look far enough in the past you will see a stock symbol trade in a similar way around certain dominant price levels. This concept of retracing is something I have learned to count on. It's also a very straight forward task to program a computer to look for. In algorithmic trading this strategy of finding price targets and stop loss levels has been very reliable. Using Fibonacci Retracements is a successful way to skim profits at pre-determined percentage levels to get in and get out of a trade in hours or days.

Below is information about how to programmatically find price levels to enter into a trade where there has been many previously successful trades. The strategy here, is that your expecting a scenario that has happen dozens of times in the past with success, to repeat in the future the same way.

##### Step: 5

"Finding Target Prices and Stop Loss Levels ". For the next step in the series, click below.

### Pivot High / Pivot Low

One way to have a computer determine support and resistance levels are pivots. In this example you can see that a 55 period pivot high / low makes it obvious where general support and resistance price levels are. The green line represents the pivot high and the purple the pivot low.

### How The Pivot is Interpreted

For the algorithm to make sense of how the stock symbol trades we are going to collect up all the pivots and tag them as a support level or a resistance levels. By doing this we will be able to later filter them to discover dominant levels. These levels are most often around easily broken down US dollar levels like \$34.00 or \$34.25. With the price action removed the dominant levels are easier to see.

### How Dominant Levels are Discovered

Once all the levels are input into a database the software will calculate dominant levels by how many times price has bounced off of a pivot point. Because it usually is not exact we will define a pivot as needing to bounce within 1/2% of a level. For example lets say we have a pivot at \$34 and we have another 171 pivots between \$34.17 and \$33.83. The system will designate \$34 a significant level

### Merging an Alert with a Dominant Level

When an indicator alert is triggered the system will first talk to the support and resistance database. This step makes sure that many times historically it has been used for support and the subsequent pivot to the high side was greater than a 1% price movement. If these 2 conditions are met, the alert will be validated and sent out with a percentage rating of how many times a greater than 1% movement has happened.

### Retracement Show Us Our Targets and Stops

When the system discovers a valid trade idea a retracement will programmatically overlay the previous pivot This will all happen automatically to generate a series of goal levels and potential stop loss levels. We next determine the price at which the alert was actually sent.

### We Want A Profit Greater Than 1%

Depending on where we enter the trade we want to pick a target level that is greater than 1% of the price of the stock. For a stop loss we want a level greater than 2% in the other direction. Stop loss levels less than 2% do not backtest well.