I have a whole bunch of data saved to a txt file, and I want to detrend it. The way I'm thinking is taking the following: x = (Last Price - First Price) / (# of bars between first and last price); then for each and every bar I'm going to apply the following formula: CurrentPrice - x; Does that sound good. I'm just asking this to see if there are any unseen pit falls
Nope. Your first part "x" is correct but your second part "what to do with x each bar" is incorrect. Try it out with pencil and paper and you'll see what you did wrong. For example assume the price bars you are working with, have the following Close prices: 32, 33, 34, 35, 36, 37. Pretty clearly there is a trend. Now try your method of removing the trend on this dataset. That'll quickly show you what the problem is.