Problems running automated strategies live

Discussion in 'Automated Trading' started by ChrisMMM, Mar 16, 2009.

  1. I have built a strategy based on a backtest. After feeling confident I went built a C++ program to run this strategy.

    I was very precise and made sure that all my calculations were correct, because any slight error would throw off the whole strategy. I'd often take a sample of data to make sure it was correct and it was.

    But I never made any money on the strategy. So I got frustered and stopped. I then looked at the backtest and saw that I would have actually would have made some money. The strategy is based on 1 minute bars, hence my strategy would calc the bars from a strating point that was random like 9:30:15 to 9:31:15 would be 1 bar. I just figured that I got a bit unlucky, so I ran it again, for like a month and still I wasn't making money.

    I again backtested the strategy and found it to be profitable. I went though my code line by line, manually calculating everything, and everything seemed right. But it just didn't match the backtest. All orders were mkt orders so I didn't have to worry about not getting fills.

    So I then forced my program to match exactly to the T what the backtest would have been, and I found something out.

    For the most part, the trades are on right on par, I reviewed every trade, and if I got a trade live and not on the backtest, I checked to see if "it was close to becoming a trade" and indeed it was.

    But then what would happen is I'd get a bunch of trades in a row that didn't match the back test. I went and compared these trades and found out there weren't even close triggering. I noticed this over and over as I continued to run this strategy. I record the prices of the stocks and matched them to what they were suppose to be and they were off.

    So I switched data feeds and notice the same thing... why???

    Every now and then the prices of stocks after the program runs go weird. I have no idea when it will happen or why it will happen. I even put a provision to check whether or not a disconnect took place. I'm assuming that the error has to be something internally with the C++ part of the program as this error happened to 2 different data feeds, but I just can't figure this out.

    Any advice would be appreciated.
     
  2. you need to isolate the source of the problem.

    eg:
    1. build simple strategy (say, if strategy is flat enter, otherwise see if it's up more than X in profit and if so exit).
    2. test simple strat on both live and sim, see if you get same trades.

    two possibilities:
    a) if you get same trades, it's your strategy.

    b) if not, it's your trading system.

    if a happens... then take once piece of your strategy code and incorporate it into the simple system. then repeat test until you find the problem.

    if b happens... you've got a problem with your trading platform... which means you gotta debug it and figure out whats going on. if it's a simple trading platform it should be easy to isolate... if it's a complex one, good luck... if your strategy is working and not incredibly complex you might just consider flipping your strategy to another platform.

    I hate stuff like this... this is the exact reason I open sourced tradelink... so people could use same strategy to backtest and trade live with and be able to debug entire thing at source code level if there are problems. (so I can relate to your pain).

    good luck!
     
  3. FaceOff

    FaceOff

    I've had similar issues in the past. I found it to be a basic coding error. Also, make sure you are not using indicators which get "repainted" like Zigzag - they will backtest differently to how they trade live.

    Also, IMO backtesting results are pretty much worthless - the markets are in a constant state of flux, so you need to forward test in order to determine if your strategy will be profitable or not.
     
  4. That's what I heard, but the same profitability carries forward
     
  5. Whenever you take a trade you need to be logging every parameter that matters at the time the trade was taken. Otherwise you will never be able to figure out why your live results deviate from your simulated results.
     
  6. Why do people try and make money on extremely short timeframes that world class programmers and traders are they doing all sorts of things to make life difficult.

    Learn to make money on a long timeframe so you can have a dayjob and not worry about a power shortage killing your account.
     
  7. To put it another way ... if you backtest and it loses money you can be pretty sure it will continue to lose money. If you backtest and it makes money you have a chance to make money, but no guarantees.
     
  8. psytrade... good advice in general.

    there will always be an appeal to daytrading however, as you can't beat the appeal of being flat when the market closes.

    obviously not always possible if you're trading billions, but it works for millions which is enough capacity for most people.