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.
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.