Using simulation to discover optimal stop loss

If you are a discretionary trader then you may have wondered what the optimal stop loss and target might be. One answer is to use simulation and the power of optimization in an attempt to find universal optimums under given conditions.

A strategy is developed that will enter randomly but only under certain conditions: the optimizer is left to solve for the optimal stop loss and target. The idea behind this approach is that your entries will either be good or will be random. If they are good you will probably hit your target fast but if they are random: you will be trading an optimal strategy to minimize your losses on those random entries (this may or may not be true but seems rational). I first read about a similar approach from Shaun Overton’s blog at OneStepRemoved.

While you could just create a random entry system, it makes sense that filtering the entries should yield more useful information. The simplest filter is to limit the trades to the time window when you will be typically trading. It probably makes sense, also, to look at longs and shorts independently.

On consideration, I suspect that the optimal stop loss for the random entry system will have a direct relationship to the average true range. Because, if you enter trades at random within a chop zone then logically you will be most likely to win if your stop is outside that zone and your target is inside that zone. In addition, if larger targets or stops are permitted then they may be favored because they will reduce the number of random entries.

Below is an early skeleton Easylanguage script implementing the idea. You could extend this code by adding conditional filters that will only allow a trade when additional conditions are met. These additional filters could be proxy conditions that might indicate a potential trade, such as a new high or low.

I am not sure how much value this approach might yield, yet. I think as one works on various conditions and filters that certain patterns might become evident that could be useful. Do you think this approach could have merit? If you are looking to capture a minimum move then you could always fix the target and only allow for the stop loss to vary (or you could fix the stop loss and only allow for the target to vary).

//Be sure to enable LIBB. Choose appropriate time and filters.
//Dummy variable is used to multiply the number of simulations
inputs:
StopSize(1), TargetSize(1), Dummy(1);

If time >=930 and time < 1200 then begin

//25% of bars
	if Random(100) <= 25 then begin
		Buy next bar at market;
	end;

	if Random(100) <= 25 then begin
		//Sell short  next bar at market;
	end;

Setstopcontract;
Setstoploss(StopSize*bigpointvalue);
Setprofittarget(TargetSize*bigpointvalue);
end;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s