Linear Regression Time Adjustment


Category:
0
0

Linear Regression line adjust according to price.  Can you create a script to stop the adjustment at a specific time?  I want it to stop at 7am est.  Thank you!

Heres the script from tos:

input price = close;

plot MiddleLR = InertiaAll(price);
def dist = HighestAll(AbsValue(MiddleLR – price)) * 0.5;
plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR – dist;

MiddleLR.setDefaultColor(GetColor(1));
UpperLR.setDefaultColor(GetColor(1));
LowerLR.setDefaultColor(GetColor(1));

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on August 17, 2020 5:00 pm
156 views
1
Private answer

Sorry but this is not at all possible with the code you have provided. The code uses two functions that read values from every single bar on the chart:

InertiaAll()

HighestAll()

There is no way to force this code to compute based on a specified number of bars or for a specified period of time.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 17, 2020 5:12 pm
0
Is there a way to alter this script to have it only calculate for prior day only so it won't adjust for current day? If its a difficult task I'm willing to pay. Thanks Hahn
( at August 20, 2020 6:36 am)
0
The very same issue in the code that prevents your original request from being completed will also prevent your second request from being completed. The only option you have is to use one of the following studies included on Thinkorswim: "StandardDevChannel" or "StandardErrorChannel"
( at August 20, 2020 9:07 am)
0
Thank you I'll check it out.
( at August 20, 2020 1:01 pm)
0
StandardErrorChannel and StandardDevChannel still repaints like the LinearRegression. I guess theres no channel scripts that stay static. Thanks for your help though Hahn. I'll keep searching
( at August 20, 2020 9:14 pm)
0
So if you want a channel that does not "repaint" why not just use a drawing object?
( at August 21, 2020 7:44 am)
0
There may be a solution if you can use one of the two studies I listed in my previous comment. I don't know for certain because despite reading your last comment several times I still don't have a clue what you are describing. But I do understand that you would like a version of this that only plots it's values for a specified period of time. From a specified start time to a specified end time. This is way beyond the scope of something I can cover free of charge in the Q&A forum. But it very well may be possible.
( at August 21, 2020 7:31 pm)
0
If it can be done I will pay as it is important for my data tracking gappers. Excuse my previous comment above. As long as it remains static and does not repaint I will be extremely happy. Thank you
( at August 21, 2020 7:56 pm)
0
I took some time to explore the options available. Unfortunately it seems we can't get there using existing tools in Thinkorswim. We can control when the channel begins but we cannot choose the end point. The function will always compute the value to include the current bar being traded on the chart. (repainting)
( at August 22, 2020 8:30 am)
0
Thanks anyways Pete!
( at August 22, 2020 4:48 pm)