top of page

Wait For Big Profit - Stop On Little Loss


There is a well-known mistake usually made by the novice investors: holding the asset in the loss forever(until the asset profits), selling the asset immediately as soon as it profits. Let’s say we are going to invest 10 times. And let’s assume we make good decisions and we will guess the direction of asset price right 9 times out of 10. If we take profit 9 times at %1 profit and wait for the asset come back to the profit area at 1 wrong estimation time and let the asset loss %10 percent, we will earn nothing even if we make good estimations.

In this algorithm, we are going to buy stocks friday evening without looking at any technical or fundamental indicator. Next week we are going to wait for the stock rise a lot to realize the profit and we are going to stop loss if the stock falls a little. We will define two variables: TAKEPROFITMARGIN, STOPLOSSMARGIN. Let’s say we will assing these variables as TAKEPROFITMARGIN = 20% and STOPLOSSMARGIN = 5%. When backtesting we are going to change these values and try to increase the performance of the algorithm.

  • On every day closure do this:

    • If it is Friday and there is no stock in account

      • Buy stocks with all available money

      • Record buy price as BUY

    • Else if there are stocks in the account

      • Record closing price as CLS

      • Calculate profit as PROFITPERCENT from CLS and BUY


        • Sell all the stocks

        • Hold the stocks (do nothing)

Implementation with C#

There are two important varialbles in the algorithm:

this._takeProfitMargin = 30; // take profit if the profit is over 30%

this._stopLossMargin = -5;  // stop loss if the loss is over 5%


When backtesting we are going to change the values of this varilables and try to find the best take profit and stop loss margin values.

Backtest Results

We are going to analyse the algorithm starting from 01.07.2016 to today(11.02.2018) on GSBD stock. GSBD price is almost the same on 01.07.2016 and today meaning investment on GSBD returns almost nothing during this period. We will try profit during that time by using the algorithm.

Here are the backtests results:

From the backtest results we can state that the keeping take profit margin small is a bad idea where as keeping the stoploss margin high is a bad idea too. If the take profit margin is 50, regardless of the stoploss margin algorithm profits the same. So, to guarantee the profit, take profit margin should be kept large and stoploss margin should be kept small.

bottom of page