bobbybones
New member
I want to backtest linear regression standard deviations, though the linear regression value is constantly changing. Is it even possible to backtest?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Ok sorry for the lack of clarity, I mean like make a strategy in tos.@bobbybones It would help if you were to define your interpretation of "backtesting"... What is it that you would be monitoring for with said backtest...??? Give us more details and perhaps we can come up with answers or suggestions... You brief request has left nothing but questions... Remember, we can't remotely read what it is that is going on in your mind - at least not that we'd admit to...
Ok sorry for the lack of clarity, I mean like make a strategy in tos.
Like you know the built in strategies in tos? Like it “places” a buy order and a sell order based on certain criteria. I want it to buy when it hits the 1.5 deviation and the 2 deviation and sell at the mean.Again, based on what details...??? What do you consider a "strategy"...??? We need details... Your request is like me asking you the question, "How long is a piece of string?"...
Like you know the built in strategies in tos? Like it “places” a buy order and a sell order based on certain criteria. I want it to buy when it hits the 1.5 deviation and the 2 deviation and sell at the mean.
yes but you must define a static timeframe/bars back you want the study to scan for and it would have to be manual live scan unless you are fine with 3-7 of delayed data as thats how tos works on watchlists.I want to backtest linear regression standard deviations, though the linear regression value is constantly changing. Is it even possible to backtest?
The problem with deviation channels and mean is that it sorta does what people refer to as repaint(i dont like that term). Think about it this way lets say you run a lap between 5-10 mins the average is 7.5, if you run the last lap in ten minutes than you probably think that the next lap should be faster or revert to the center. But when there is more data or if you keep running at 10 mins the mean will not be the same anymore, even more so if you run more than 10 min, so then the channels keep changing, and the deviations keep changing, you could look at more data(bigger time frames) because the more data you the less the probability that the mean or average will change, but its very difficult to see what the channels have done unless you use the on-demand feature, there is a guy that uses primarily deviation channels, its the boiler room on thinkorswim, but as far as backtesting its, I dont know how you would do it, you can backtest something that keeps changing, having said that I do think that regression channels work if you use them multitude frame, because the deviations are truer on higher time frames, and they don't "deviate" as much. Look i to what standard deviations are i. Statistics and you'll understnad.Like you know the built in strategies in tos? Like it “places” a buy order and a sell order based on certain criteria. I want it to buy when it hits the 1.5 deviation and the 2 deviation and sell at the mean.
Yeah I know boiler room trading personally and have been using his system to trade and it works pretty well. I’m just trying to optimize it, which is why I need more data, such as trades I might have made. Back testing it manually will be a huge pain in the ***, but I guess I’ll have to do it. Thanks for your help.The problem with deviation channels and mean is that it sorta does what people refer to as repaint(i dont like that term). Think about it this way lets say you run a lap between 5-10 mins the average is 7.5, if you run the last lap in ten minutes than you probably think that the next lap should be faster or revert to the center. But when there is more data or if you keep running at 10 mins the mean will not be the same anymore, even more so if you run more than 10 min, so then the channels keep changing, and the deviations keep changing, you could look at more data(bigger time frames) because the more data you the less the probability that the mean or average will change, but its very difficult to see what the channels have done unless you use the on-demand feature, there is a guy that uses primarily deviation channels, its the boiler room on thinkorswim, but as far as backtesting its, I dont know how you would do it, you can backtest something that keeps changing, having said that I do think that regression channels work if you use them multitude frame, because the deviations are truer on higher time frames, and they don't "deviate" as much. Look i to what standard deviations are i. Statistics and you'll understnad.
input price = close;
input deviations = 2.0;
def regression = InertiaAll(price);
def stdDeviation = stdevAll(price);
plot UpperLine = regression + deviations * stdDeviation;
plot LowerLine = regression - deviations * stdDeviation;
def crossAbove = price crosses above upperLine;
def crossBelow = price crosses below lowerLine;
def buy = crossBelow;
def sell = crossAbove;
AddOrder(OrderType.BUY_AUTO, buy, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "StdDevStratBUY");
AddOrder(OrderType.SELL_AUTO, sell, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "StdDevStratSell");
I’m sorry for not being as clear as you wanted. I’m talking about linear regression standard deviations.So, which Study are you referring to... This is like pulling teeth...!!! Can you write more than two sentences to describe things in detail...??? I honestly don't like having to pry information out of you... It's you who wants the help and you're wasting MY time, and anyone else's who is following this topic...!!! Figure it out yourself if you can't explain yourself... It's you vision, not ours...
Sorry for not being as clear as you’d like. I’m taking about the linear regression trend and standard deviations from the linear regression trend. I want to buy when it hits the lower deviations and sell when it hits the mean. I don’t know what other details to include, as it’s a simple strategy.So, which Study are you referring to... This is like pulling teeth...!!! Can you write more than two sentences to describe things in detail...??? I honestly don't like having to pry information out of you... It's you who wants the help and you're wasting MY time, and anyone else's who is following this topic...!!! Figure it out yourself if you can't explain yourself... It's you vision, not ours...
It is standard deviations of the linear regression. Anyway i can't force you to stay, sorry for wasting your time. Take it easy.@bobbybones So we've gone from Standard Deviations to Linear Regressions... I don't like having my chain rattled... I'm out...!!!
Good luck...!!!
def barsBack = # some magic
def regression = Inertia(close(period = AggregationPeriod.DAY)[barsBack], length);
HighestAll(BarNumber()) - BarNumber()
. I've never tried something like that.Hey man, I'm with you. Nothing you said above was "vague" to me. This is exactly what I've been playing around with for a couple of days. And as I started looking at just a 2.0 Std Dev Channel on a 20 Day/1Hr chart, it suddenly dawned on me why I get my arse handed to me nearly every time I try and jump on a "hot stock" and ride it...namely, I'M BUYING AT THE TOP of the move! Now I know why a stock starts to drop like a rock, sometimes literally less than 5 minutes after I buy! This was an epiphany for me and I've been doing this a long time...It is standard deviations of the linear regression. Anyway i can't force you to stay, sorry for wasting your time. Take it easy.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.