Trading Evolution

Markets are never wrong - opinions often are

Risk/Reward, Win/Loss and losing streaks

Risk/Reward vs. Win/Loss

Quite often people talk about risk/reward ratios they prefer to trade. For example some prefer to trade with risk/reward 1:2 or to risk $100 to make $200, some prefer 1:3 or to risk $100 to make $300. Based on preferred risk/reward ratio it is possible to calculate win/loss ratio needed to stay profitable. The formula is 1/(risk_reward + 1). For 1:2 it would be 33% which means one needs to hit winning trades at least 1/3 of time to stay profitable. Which makes sense, if you lose $100 twice and make $200 you stay break-even and if you win more times than that you stay profitable. The relationship can be easily plotted like this

Losing streaks

Now novice trader might find a trading system which wins 30% of a time with risk/reward 1:3 and might expect to make $3,000 over 100 trades by risking $100 and expectation of $300. So how much capital do you need to trade this strategy? Some might say you can have 5-6 losing trades in a row or a drawdown of $600 and then come back. Not so fast. If you apply simple math. Trader should absolutely expect to hit 13 losing trades in a row or $1,300 drawdown over 100 trades and he is not prepared to handle it look for different strategy. The formula for probability of number of losing trades is quite simple. You take probability of loss (70% in our case) and multiply it by itself. For 13 trades it would be 70% * 70% * 70% * 70% ... = 1% which means out of 100 random sequences of trades at least 1 would consist of all losing trades. Relationship between win/loss ratio and at least 1 expected losing streak length can be plotted like this:

As you can see from the chart above even for 50/50 trading system a trader should expect to hit at least one streak of 7 losing trades in a row out of 100 trades which has nothing to do with quality of his trading system.

Rate hikes are on hold for now

After today's FED announcement it is clear that any future rate hikes this year are on hold until further notice.

  • "Economic activity has been expanding" - gone. Replaced with "Economic growth slowed late last year" and "inventory investment slowed"
  • "Inflation is expected to to rise to 2 percent" - gone. Replaced with "Inflation is expected to remain low"
  • Risks added "closely monitor global economic and financial developments and is assessing their implications for the labor market and inflation, and for the balance of risks to the outlook"

All of the above indicates that unless market improves and/or economy strengthens lifting energy prices FED is on hold so if you were thinking about refinancing because you were afraid about raising interest rates, you have plenty of time.

How to attach stop loss order to any order

Everybody knows that stop loss orders are important. Interactive Brokers API allows you to send an order with attached stop loss so you don't have to write code to monitor when order is filled then you place your stop order. You can send your order and attached stop loss order which will be monitored by Interactive Brokers and as soon as the main order is filled Interactive Brokers will activate your stop. When order is not filled and you cancel it stop loss order will be cancelled as well.

var entryOrder = new IBApi.Order();

entryOrder.OrderId	= _ibWrapper.NextOrderId++;
entryOrder.Action	= "BUY";
entryOrder.OrderType	= "LMT";
entryOrder.LmtPrice	= price;
entryOrder.TotalQuantity = quantity;
entryOrder.Tif		= "GTC";
entryOrder.Transmit	= false;
_ibWrapper.IBClient.placeOrder(entryOrder.OrderId, contract, entryOrder);

var stopOrder = new IBApi.Order();

stopOrder.OrderId	= _ibWrapper.NextOrderId++;
stopOrder.ParentId	= entryOrder.OrderId;
stopOrder.Action	= "SELL";
stopOrder.OrderType	= "STP";
stopOrder.AuxPrice	= stopPrice;
stopOrder.TotalQuantity	= entryOrder.TotalQuantity;
stopOrder.Tif		= "GTC";
stopOrder.Transmit	= false;
_ibWrapper.IBClient.placeOrder(stopOrder.OrderId, contract, stopOrder);

Thread.Sleep(1000); // Let IB process orders first and then transmit parent order

entryOrder.Transmit         = true;
_ibWrapper.IBClient.placeOrder(entryOrder.OrderId, contract, entryOrder);

Few things to note here. First, set stop loss order ParentId to entry order Id. Second, entry order and stop loss order are sent with Transmit field set to "false" and finally transmit entry order.

How to create an order that automatically cancels in 5 min

When you write your automated system sometimes your signal is valid only for the next 5, 10 or 15 min. It is useful to create orders that auto expire if not filled after certain period of time so you don't have to write code that cancels them. All is needed is to set Time In Force (Tif) property to "GTD" and set GoodTillDate to the time in a future you want this order to expire if it is not filled. In the example below I used DateTime.Now.AddMinutes to add 10 minutes to current time.

var order = new IBApi.Order();

order.OrderId = _ibWrapper.NextOrderId++;
order.Action = "BUY";
order.OrderType = "LMT";
order.LmtPrice = price;
order.TotalQuantity = quantity;
order.Tif = "GTD";
order.GoodTillDate     = DateTime.Now.AddMinutes(10).ToString("yyyyMMdd HH:mm:ss ");

_ibWrapper.IBClient.placeOrder(order.OrderId, ..., order);