StockFetcher Forums · Filter Exchange · VOLATILITY-BASED STOP LOSSES AND POSITION SIZING<< 1 2 >>Post Follow-up
Kevin_in_GA
4,599 posts
msg #117617
Ignore Kevin_in_GA
modified
1/6/2014 12:32:52 PM

I wanted to share a little strategy that can be added to almost any SF filter to help manage risk.

Imagine that you had $100,000 to trade. Many novice traders might jump right in and decide to invest a substantial amount of this equity in one particular stock or a few stocks. Perhaps they decide to buy 10,000 shares of a single stock because the price is only $4.00 a share (or $40,000). They have no pre-planned exit or idea about when they are going to get out of the trade if it happens to go against them, and are risking a LOT of their initial capital unnecessarily.

Seasoned traders usually determine the maximum amount they are willing to lose, and set a stop loss that will trigger if that amount is hit. Suppose you have a portfolio of $100,000 and you decide to only risk 1% on a trading idea that you have. You are risking $1,000 and no more on any trade. The seasoned trader looks at the same $4.00 stock but enters the trade with a clear exit strategy and defined amount at risk.

Now suppose you decide to buy that same $4.00 stock. How can you determine the number of shares and the position of the stop loss so that you are only risking $1000? Ideally you do not want the stop loss hit - it is a protective feature but once hit it closes the trade at a loss. It should not be hit due to the natural intraday movement of the stock's price so you don't want the stop loss too tight, but neither should you set it at something too large or it won't be giving you the protection you are anticipating.

One simple approach used by many traders is to simply set the stop at a specific percentage drop from the entry price - say 5% or 10% below the entry, and from that number they can determine the number of shares they should buy. For example, the number of shares you would buy of that $4.00 stock with a 5% stop loss would be calculated as follows:

the absolute amount willing to lose = $1000
the absolute drop in value at 5% = 4.00 x 0.05 or 0.20

the number of shares to purchase = 1000/0.20 = 5000 shares.

This works, but fails to take into account the natural daily fluctuation in stock price - what if this particular $4.00 stock moves more than 5% every day? Or every week? You could easily be stopped out before the stock has a chance to move upward, locking in a loss instead of a gain. This is exactly why many people are reluctant to implement stop losses ... they do not properly quantify this component of their trading system and get burned.

There is actually a fairly easy way to do this, and it is readily coded in SF and can be added to almost any filter you find here. Instead of using a fixed stop loss, you simply use a multiple of the ATR of the stock over a specified number of days. For the next example, I'll use the ATR(20).

We'll use two actual $4.00 stocks, but we will use the ATR(20) as our stop loss rather than a set percentage. For ZNGA the ATR(20) is 0.13, and for CSVN the ATR(20) is 0.45. You can immediately see that if we used a standard 5% stop on both of these, the risk of tripping the stop loss for CSVN is much higher than for ZNGA. So to hold our loss at $1000, we need to customize the number of shares and stop loss position for each stock, rather than just use a set percentage based on the amount of the trade. Rather, the amount of the trade is varied based on the volatility of the stock.

Example

ZNGA :
the absolute amount willing to lose = $1000
the absolute drop in value = 1 x ATR(20) or $0.13

the number of shares to purchase = 1000/0.13 = 7692 shares with a stop loss at ($4.00 - $0.13) = $3.87.
total amount in this trade = 7692 x $4.00 = $30,768

CSVN :
the absolute amount willing to lose = $1000
the absolute drop in value = 1 x ATR(20) or $0.45

the number of shares to purchase = 1000/0.45 = 2222 shares with a stop loss at ($4.00 - $0.45) = $3.55.
total amount in this trade = 2229 x $4.00 = $8,918

As you can see, a very different set of trades than what you might consider just using a set percentage stop loss. Most likely CSVN would result in a loss because the stop loss was inside the normal 20 day range of price movement.

As to how this is translated into SF code, I do it this way:

Fetcher[
symlist(znga,csvn)
SET{SHARESTOBUY, 1000/atr(20)}
set{positionamt, close * sharestobuy}
set{stoploss, close - ATR(20)}

add column sharestobuy {shares to buy}
add column stoploss {stop loss}
add column positionamt {trade size}

]



As you can see this snippet of code can be added to any filter you use here, and will allow for dynamic trade sizing based on volatility (this is exactly what Van Tharp did that made him one of the more successful traders in history).

One can also use 2 x ATR(20) with a correspondingly smaller number of shares purchased - the exact settings are customizable so that any trader can adjust them to his/her risk tolerance.

Enjoy.

Kevin

alf44
2,025 posts
msg #117623
Ignore alf44
modified
1/7/2014 1:55:40 PM

.

... I assume the Initial Stop Loss on a SHORT would be ... Close + ATR(20) ???

.

Kevin_in_GA
4,599 posts
msg #117627
Ignore Kevin_in_GA
1/7/2014 5:08:32 PM

Yup - this risk management strategy is directionally independent.

alf44
2,025 posts
msg #117628
Ignore alf44
modified
1/7/2014 5:25:16 PM

.

Kevin ...

... as these Stop Loss calculations are intended as an "Initial" Stop Loss ... when a trade is first put on ...

got any thoughts about including "Trailing" Stop calculations ... other than maybe "Chandelier" or Parabolic SAR ... AFTER the

trade has gotten to break-even and beyond ?

.

novacane32000
331 posts
msg #117630
Ignore novacane32000
1/7/2014 7:49:25 PM

Van Tharp on Youtube http://www.youtube.com/watch?v=QjFRVPWpEuY

agavaqif
8 posts
msg #117633
Ignore agavaqif
1/8/2014 2:37:01 AM

Hi Kevin.. I am new around here, also in trading. I am tring to create my own system. I have a question about this system:
Suppose I have got 10000$. And I can risk 5% of it which is 500%. If I buy 1 stock and apply this system then my maximum risk will be 500$. But if I buy 2 stocks should I calculate my s.loss with 1000$ risk for each ? Or 500$ for each and 1000 $ totally?

My second question is about Stockfetcher :
Suppose I filtereded with those settings: RSI(14) below 30, close below MA(50) [ It is just example] , after using filter I found suppose 5 results. And from them I chose abc stock. Is it possible to see if abs stock within past 300 days made same values. I mean may be this abs stock's RSI(14) was below 30, close was below MA(50) just 2 month ago . Is it possible to see it?

Thanks..

Kevin_in_GA
4,599 posts
msg #117647
Ignore Kevin_in_GA
1/8/2014 10:06:27 PM

Trading an amount as small as $500, you are going to be hard pressed to make any real gains - at an average commission rate of $8 per trade (buy and sell), you lose more than 3% on every trade, so whatever system you come up with had better return more than that as an average or you are sure to lose money. Absolute trade size is an important consideration.

mahkoh
1,065 posts
msg #117656
Ignore mahkoh
1/9/2014 2:59:27 PM

I guess this is where the new MaxDD() function comes in handy.

Kevin_in_GA
4,599 posts
msg #117657
Ignore Kevin_in_GA
1/9/2014 3:28:53 PM

I have been focusing on risk management of late - the MaxDD() function is for determining Calmar ratios, and I'm still holding out hope for the Sharpe ratio function I asked for a while back (not holding my breath though, since I would have suffocated a long time ago). Apparently since you can spend 20 lines of code and multiple embedded user-defined functions to make it work, that is good enough for SF.

This approach is about managing position sizing and stop loss placement, so it is more about teaching the providing a simple function. Too many traders simply aren't aware of this part of good trade management (I wasn't for a long time). I'm using it now as part of my Pangolin systems and so far it is working nicely.

mahkoh
1,065 posts
msg #117661
Ignore mahkoh
1/9/2014 4:44:11 PM

What I did is the following:

Fetcher[
s&p 500
add column maxdd(20)
set{x,atr(20) 20 days ago/close 20 days ago}
set{atr%,x*100}
add column atr%
]



Download the csv file; in column F copy down =E2/F2; in column G copy down =IF(G2>J$1,1,0)

In cell J1 enter the value to multiply atr(20) with, e.g. 2
The Sum value for column H indicates how many times a stop would have been triggered at 2*atr(20) for the 200 stocks.

This is pretty random but it gives a feel for where the stoploss should be.

StockFetcher Forums · Filter Exchange · VOLATILITY-BASED STOP LOSSES AND POSITION SIZING<< 1 2 >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.