Hello, Rather than reinvent the wheel I am trying to identify a formula that will optimize the amount of stock to hold for a stock that oscillates between 1 and 100. At $1 we want to be 100% invested in the stock. At $100 we want to be all cash. Is there a formula that would optimize this process? A very simply option may be to hold the following % of stock at these points. How do I translate this to a formula? I assume I would want to buy at lower pricepoints than I sell at so we set the following table to buy on the way up and have another table to buy on the way down. In theory this works, but there must be a formula to automate this. Buy on way up Price % Invested $0 0% $10 10% $20 20% etc $90 90% $100 100% Sell on way down Price % Invested $100 100% $92 90% $82 80% $72 70% etc $22 20% $12 10% $0 0% Any help would be appreciated.

Your $1→$100 range is a bit distracting -- If we suppose a range away from $0, that would help. So: Let's say the stock is $12.50, and at $10.00 you want to be 100% invested, and at $15.00 you want to be 100% in cash AND that this is symmetric. So, at $12.50, you'd be at 50%. Were this a new position being considered, and you've got $X_amount of cash ready to go, then take half that money and buy the stock at market. Now, you've got to remember that your rubric leaves you at 50% of range and 50% of cash, and your conditions are satisfied, so it's time to sit on your hands. Now, you need a trading regime: so, per-week? Per--month? Even per-day?? Whatever: when the stock moves over your trading regime time period, you respond -- formulaically. Down a percent? Then another percent of the original value (from cash, now!), goes in. Up a percent? Then a sale of the number of shares that were purchased at $12.50 (notice that change in decision point?) That will take you to $10 or $15 as the market allows.

The real life range has been a consistent oscillation between 10 and 200 for the last 5 years. It has rarely gone under 20 and rarely gone over 120. I picked 1-100 for my example to make it easy. I need a formula instead of a table. It needs to work off a percentage as the assumption is I gain over time. I will likely buy/sell every 2-3% move. However I need help creating the algorithm. I am going to try the linear regression, but I doubt it takes into account that I am buying lower than I am selling.

By combining linear regression with sample numbers I generated the following buy/sell table from 9-102 BUY Table Count Buy per 1 % holdings 9 10000000 91.92% 14 5000000 86.87% 19 2000000 81.82% 24 1500000 76.77% 29 1000000 71.72% 34 900000 66.67% 39 800000 61.62% 44 750000 56.57% 49 700000 51.52% 54 650000 46.47% 59 600000 41.42% 64 550000 36.37% 69 500000 31.32% 74 450000 26.27% 79 400000 21.22% 84 350000 16.17% 89 300000 11.12% 94 200000 6.07% 99 100000 1.02% SELL Count % holding 12 950000 88.89% 17 570000 83.84% 22 95000 78.79% 27 95000 73.74% 32 19000 68.69% 37 19000 63.64% 42 9500 58.59% 47 9500 53.54% 52 9500 48.49% 57 9500 43.44% 62 9500 38.39% 67 9500 33.34% 72 9500 28.29% 77 9500 23.24% 82 9500 18.19% 87 9500 13.14% 92 19000 8.09% 97 19000 3.04% 102 9500 -2.01% Not sure this is optimized

Here is a graph of the last 5 years. It actually trades between .000000200 and .000000010 with the majority between .000000120 and .000000020 so this will be my range. Above 120 I will hold nothing. Below 20 I will hold max. I am going to toss $10,000 of house money at this if I can get a working algorithm. Transaction fees are 0.1%

On the sample you show, it has popped 7 months out of 55 shown. A) if that were any sort of indication, it's about to decline. B) that size is too small a sample size for any sort of indication. I wouldn't put even beer money on it. ('Free advice being worth what you paid for it', and all.)

I think that you are not consistent. At first you write "At $1 we want to be 100% invested in the stock. At $100 we want to be all cash." But the table shows that at price $100 you are 100% invested. What makes your question a bit more complicated is your definition of %. Percentage of what are you referring to? Is it a percentage of the maximum amount/quantity of the stock? Or is it a percentage of your overall account value (in USD)? If the latter, the calculation is more complicated because your account value will fluctuate if this stock price changes. And your account value fluctuates if you are holding other positions as well.