Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: Fun with ThinkScript
May 28, 2015 11:42PM
That's great - thanks for the help
Re: Fun with ThinkScript
May 29, 2015 12:03AM
Thank you for the code Robert!
Re: Fun with ThinkScript
May 29, 2015 07:00AM
Quote
SKumar
Thank you for the regression channel angle script. That's awesome. Is there a way to apply the angle on MACD to distinguish good crossovers from bad ones as I requested before?

I don't think it will work out as well as one might have hoped. The angles look alright on a daily chart, but on the intra-day charts the angles become so small as to be almost unusable. The script is below, though, if you wish to test it out.

Best of luck.





declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);

plot Diff = Value - Avg;
plot ZeroLine = 0;

Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up" ) else Diff.Color("Positive and Down" ) else if Diff < Diff[1] then Diff.Color("Negative and Down" ) else Diff.Color("Negative and Up" ));
ZeroLine.SetDefaultColor(GetColor(0));

# ----- apply linear regression slope to macd line -----
def LRlength = 3;
def angle = ATan(LinearRegressionSlope(Value, LRlength)) * 180 / Double.Pi;
AddLabel(yes, "macd slope angle: " + round(angle,1), Color.WHITE);


Quote
SKumar
A tip has been added in your tip jar

Thank you very much!

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
May 29, 2015 07:40AM
Ha! That was such a simple stupid error! I guess my brain wasn't functioning properly after all these days of trying to figure out how to script/code and whether I should even bother to script stuff in Java so that I can just use the platform that I like for placing orders. Thinkscript is way easier though so I'll just stick with TOS for the charts. Thanks for helping and even making the script way better! Now on to figure out how to script the thing I really want to script....
Re: Fun with ThinkScript
May 29, 2015 02:57PM
Hi Robert,
This is a great tool, but I would like to add labels next to the label date with the expected move (GetMarketMakerMove) before earnings and the actual % and $ change after earnings. Also the implied volatility drop after ER and finally the average price movement after X number of days after ER.
I know it's not easy, I'm in the process but I realized have a lot to learn with scrips.

If you can add those indicators I wuold be glad to buy the whole package.
Thank you.
Re: Fun with ThinkScript
May 29, 2015 05:37PM
Thanks Robert. Let me play around with it and see...

Thanks a lot

Regards

S Kumar
Re: Fun with ThinkScript
May 29, 2015 08:06PM
Robert,
Here is another one for you..I know TOS has a lookback restriction for scanning at 2 years, I believe but..I am looking for a scan that will look for all stocks breaking out above the highest RSI and/or MACD of the last three years or as close to that as possible..but would also like to capture IPO's that may have less than say 125 trading days but still new RSI and/or MACD highs so maybe have the period def to the max allowed..

I would like to be able to define the RSI as well with values of 69.10 and 30.90

another tip headed your way..btw, I have purchased several of your indicators from your site.. absolutely great work and with TOS finally fixing their boggin of real time scanning, it is more useful than ever..
Re: Fun with ThinkScript
May 30, 2015 08:16PM
Robert,

Thank you for your latest reply. Based on the latest iteration of the thinkscript you've so generously provided, I've run into what looks to be an anomaly and I'd be interested to hear your thoughts...

Essentially, a number of results returned in a scan set do not fit the specified scan condition. For example, using the provided script with the default inputs:
# scan for downwardly sloping channels
# manually change the input values as needed before pasting into the scan tool
# length of linear regression channel
input length = 100;
# filter out all channels with an angle that is less than the minimum specified angle
input minAngle = 20;

# --- do not change anything below this line ---
def angle = ATan(LinearRegressionSlope(length = length)) * 180 / Double.Pi;
plot signal = angle < 0 and absValue(angle) >= minAngle;
The Scan criteria look like this:



Running the Scan yields the following:
- Total results: 26
- Results with undesirable positive slope: 10

If I'm guessing correctly, the "angle < 0" portion of the new script may possibly be the cause. Below please find a couple of samples illustrating the issue...

Samples of returned undesirable positive slope results:

SSYS


DRQ



Sample of returned desirable negative slope result:

TDW


One more sample, if I may. The sample provided below has a desirable negative slope. However, the slope of the Linear Regression Channel is almost flat. Although this satisfies the "angle < 0" filter, I think it fails the "minAngle >= 20" filter...

AEGR


If time and circumstances permit, I look forward to your reply to this issue. Thanks again!
Re: Fun with ThinkScript
May 30, 2015 11:18PM
Quote
netarchitech
If time and circumstances permit, I look forward to your reply to this issue. Thanks again!

If the goal it to plot a 100 period linear regression channel, then LinearRegCH100 is not study to use. That study does a linear regression over the entire length of the chart. The 100 in that study doesn't refer to a channel with a length of 100 bars, but to setting the width of the channel to 100% of maximum.

Instead, use the LinearRegChVar study with the following settings.





- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
May 31, 2015 05:07AM
Quote
RTAVERA
Hi Robert,
This is a great tool, but I would like to add labels next to the label date with the expected move (GetMarketMakerMove) before earnings and the actual % and $ change after earnings. Also the implied volatility drop after ER and finally the average price movement after X number of days after ER.
I know it's not easy, I'm in the process but I realized have a lot to learn with scrips.

If you can add those indicators I wuold be glad to buy the whole package.
Thank you.

Done

GetMarketMakerMove() was not incorporated, though, because the vast majority of the time it returned a value of N/A. The few stocks that it did work on returned the same value for every earnings release date which leads me to believe that either the indicator only reports the current MM prediction, or that it is bugged. Either way, I didn't want to include a function that did not work.

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
May 31, 2015 05:14AM
The Eagle Eye layout is an enhancement to the popular Bird’s Eye View earnings research tool. Several valuable data points are displayed that allow the user to conduct more detailed earnings research.

This is available on my blog.



- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
May 31, 2015 06:11AM
Robert,
Here is another one for you..I know TOS has a lookback restriction for scanning at 2 years, I believe but..I am looking for a scan that will look for all stocks breaking out above the highest RSI and/or MACD of the last three years or as close to that as possible..but would also like to capture IPO's that may have less than say 125 trading days but still new RSI and/or MACD highs so maybe have the period def to the max allowed..

I would like to be able to define the RSI as well with values of 69.10 and 30.90

another tip headed your way..btw, I have purchased several of your indicators from your site.. absolutely great work and with TOS finally fixing their boggin of real time scanning, it is more useful than ever..
Reply Quote
Re: Fun with ThinkScript
May 31, 2015 07:41PM
Robert,

Thank you for your recent reply. I greatly appreciate each of your thorough and informative responses, especially since it all started with a "proof of concept"...

Quote
Robert
If the goal it to plot a 100 period linear regression channel, then LinearRegCH100 is not study to use. That study does a linear regression over the entire length of the chart. The 100 in that study doesn't refer to a channel with a length of 100 bars, but to setting the width of the channel to 100% of maximum.

Instead, use the LinearRegChVar study...

Actually, I've always been looking to use the percentage aspect of the LinearRegCh. Since I need to have the flexibility of switching aggregations on the fly, I think it is far simpler to do so with the dynamic aspect of LinearRegCh100, as opposed to the more static approach of say LinearRegChVar...

Given the latest iterations of the scripts:
# scan for upwardly sloping channels
# manually change the input values as needed before pasting into the scan tool
# length of linear regression channel
input length = 100;
# filter out all channels with an angle that is less than the minimum specified angle
input minAngle = 20;

# --- do not change anything below this line ---
def angle = ATan(LinearRegressionSlope(length = length)) * 180 / Double.Pi;
plot signal = angle >= minAngle;
# scan for downwardly sloping channels
# manually change the input values as needed before pasting into the scan tool
# length of linear regression channel
input length = 100;
# filter out all channels with an angle that is less than the minimum specified angle
input minAngle = 20;

# --- do not change anything below this line ---
def angle = ATan(LinearRegressionSlope(length = length)) * 180 / Double.Pi;
plot signal = angle < 0 and absValue(angle) >= minAngle;
Is it possible to have the input "length" have a value interpreted as a percentage (default value = 100%) instead of a period (default value = 100 bars)?

In closing, if this is the end of the road, I want to thank you very much for your time and efforts in this endeavor. It is sincerely appreciated...

The aforementioned tip is on the way. Thanks again!
Re: Fun with ThinkScript
June 01, 2015 04:34AM
Quote
netarchitech
Is it possible to have the input "length" have a value interpreted as a percentage (default value = 100%) instead of a period (default value = 100 bars)?

I don't think so. I've been messing with it for about an hour now and every time I try to set a computationally generated length for use with the InertiaAll function (this is the function that actually calculates the linear regression) ThinkScript returns an error stating that only constants are allowed.

For instance, a 1 year daily chart has 252 bars. The LinearRegCH100 study will compute the linear regression channel using all 252 of those bars.

If I want to plot a linear regression using only 50% of the length of that chart—126 bars—ThinkScript seems to have a problem with that. It is an easy matter to calculate the number of bars and divide by two. I can even add a label on the chart the displays both the total number of bars and half of that value. That value can be used in other calculations. No problem. However, when I try to pass that value to the InertalAll function as the length to be used for calculating the linear regression channel, ThinkScript returns the error "Only constants expected here." I have been unable to figure out a workaround.

If you choose to use the scans presented previously, then the following script will plot the corresponding linear regression channel (default length 100) and slope.



script LR {
    input y = close;
    input n = 20;
    input x = 1;
    def l = 3 * n;
    plot a = (n * Sum(x * y, l) - Sum(x, l) * Sum(y, l) ) / ( n * Sum(Sqr(x), l) - Sqr(Sum(x, l)));
    plot b = (Sum(Sqr(x), l) * Sum(y, l) - Sum(x, l) * Sum(x * y, l) ) / ( n * Sum(Sqr(x), l) - Sqr(Sum(x, l)));
    plot lr = a * x + b;
}

input length = 100;

# determine last bar, not counting extended area
def LastBar = HighestAll(if IsNaN(close) then 0 else BarNumber());
# determine when the LR channel begins
def LRbegin = if BarNumber() == (LastBar - length + 1) then BarNumber() else LRbegin[1];

def modY = if !LRbegin then 0 else close;
def modX = if !LRbegin then 0 else BarNumber();
# calculate the linear regression values
def lr = lr(modY, length, modX).lr;
def a = lr(modY, length, modX).a;
def b = lr(modY, length, modX).b;
# plot the linear regression channel
def transpose = BarNumber() - LastBar;
plot linReg = if !modX then Double.NaN else modX * GetValue(a, transpose) + GetValue(b, transpose);
linReg.SetDefaultColor(Color.WHITE);
linReg.SetStyle(Curve.MEDIUM_DASH);
def dist = HighestAll(AbsValue(modY - linReg));
plot LRupper = linReg + dist;
LRupper.SetDefaultColor(Color.CYAN);
plot LRlower = linReg - dist;
LRlower.SetDefaultColor(Color.CYAN);

# ----- find the slope angle -----
def angle = ATan(LinearRegressionSlope(length = length)) * 180 / Double.Pi;
AddLabel(yes, "slope angle:  " + Round(angle, 2), Color.WHITE);

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 01, 2015 04:50AM
Quote
ht65
I am looking for a scan that will look for all stocks breaking out above the highest RSI



input length = 14;
def rsi = rsi(length).rsi;
plot signal = rsi == highestall(rsi);

Quote

I would like to be able to define the RSI as well with values of 69.10 and 30.90

input length = 14;
input threshold = 69.10
def rsi = rsi(length).rsi;
plot signal = rsi >= threshold;

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 01, 2015 05:53AM
Thank you Robert!

am I to assume the first code you provided can be used as a scan and then set the period to week? TOS returns some inaccurate results.. for instance [screencast.com]

also how am i to use the second snippet of code with the 69.10? as an indicator or what?
Re: Fun with ThinkScript
June 01, 2015 06:05AM
Quote
ht65
am I to assume the first code you provided can be used as a scan and then set the period to week? TOS returns some inaccurate results.. for instance [screencast.com]

The previous rsi spike on ALSK occurred nearly 2 years ago. Perhaps the weekly scan doesn't look that far back. Since all scan results are done completely behind the scenes, I have no way of verifying that. Mathematically, the formula provided should work, but the results produced will depend on how far the scanner looks into the past.

Quote

also how am i to use the second snippet of code with the 69.10? as an indicator or what?

Perhaps I misunderstood what you were asking for. I assumed that you wanted to be able to be able to scan for rsi values above a certain user-defined level such as 69.10 or 30.90. So, if you change that number, the scan will look for any rsi values above that "threshold."

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 01, 2015 09:24AM
Do you know if there's a way to turn a recursive variable into a non-recursive one? Or some way to get around using a recursive. I'm trying to set a study alert to notify me of when a new higher/lower fractal is formed and apparently recursive variables are disabled in study alerts.
Re: Fun with ThinkScript
June 01, 2015 09:53AM
Quote
bijinkei
Do you know if there's a way to turn a recursive variable into a non-recursive one? Or some way to get around using a recursive. I'm trying to set a study alert to notify me of when a new higher/lower fractal is formed and apparently recursive variables are disabled in study alerts.

It can be done with some trickery. Compare the two scripts below. Both scripts plot the 30 min opening range (the user may adjust the opening range times on either).

The first script is the 30 min opening range script that I wrote. It uses recursive variables to keep track of and plot the opening range.



def OpenRangeMinutes = 30;
def MarketOpenTime = 0930;
input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def OpenRangeTime = if SecondsFromTime(MarketOpenTime) < 60 * OpenRangeMinutes then 1 else 0;

def ORHigh =  if FirstMinute then high else if OpenRangeTime and high > ORHigh[1] then high else ORHigh[1];
def ORLow = if FirstMinute then low else if OpenRangeTime and low < ORLow[1] then low else ORLow[1];

plot OpenRangeHigh = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORHigh else Double.NaN;
     OpenRangeHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
     OpenRangeHigh.SetDefaultColor(Color.YELLOW);
plot OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;
     OpenRangeLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
     OpenRangeLow.SetDefaultColor(Color.YELLOW);

This second script is what I now use. I came up with this method when someone asked me to write an opening range breakout alert and, like yourself, I discovered that recursive variables were not allowed. Using this new method, the alert worked as intended without using recursive variables. The trick for this one is to accomplished with the lookback variable and the GetValue() function.



input agg = AggregationPeriod.Thirty_MIN; 
input ShowTodayOnly = yes;
def today = if !ShowTodayOnly then 1 else GetDay() == GetLastDay();
def lookback = SecondsFromTime(0930) / GetAggregationPeriod() * 1000;

plot ORh = if !today then double.nan else GetValue(high(period = agg), lookback);
     ORh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
     ORh.SetDefaultColor(Color.YELLOW);
     ORh.SetLineWeight(2);
plot ORl = if !today then double.nan else GetValue(low(period = agg), lookback);
     ORl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
     ORl.SetDefaultColor(Color.YELLOW);
     ORl.SetLineWeight(2);

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 01, 2015 10:43AM
I tried replacing a bunch of things with GetValue and while the plot works, the study alerts still give me that rec usage not allowed message. I think the issue is that I'm still using < and >?

input length = 34;
input lookback = 2;
input lookforward = 1;

def HP = GetValue(high,0) > GetValue(high, 1, lookback);
def HF = GetValue(high,0) > GetValue(high, -lookforward);
def HPc = if HP then 1 else if GetValue(high,0) == GetValue(high, 1) and GetValue(HPc, 1) then GetValue(HPc,1) else 0;
def peak = if HPc and HF then GetValue(high,0) else GetValue(peak, 1);


def LP = GetValue(low,0) < GetValue(low, 1, lookback);
def LF = GetValue(low,0) < GetValue(low, -lookforward);
def LPc = if LP then 1 else if GetValue(low,0) == GetValue(low, 1) and GetValue(LPc, 1) then GetValue(LPC, 1) else 0;
def trough = if LPc and LF then GetValue(low,0) else GetValue(trough, 1);


plot upperband = Highest(GetValue(peak, 1), length);
plot lowerband = Lowest(GetValue(trough, 1), length); 
Re: Fun with ThinkScript
June 01, 2015 10:51AM
Quote
bijinkei
I tried replacing a bunch of things with GetValue and while the plot works, the study alerts still give me that rec usage not allowed message. I think the issue is that I'm still using < and >?

Post your original script (the one with the recursive variables). Also, tell me how you want the alerts to work. I'll take a look and see if something can be worked out.

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 01, 2015 10:55AM
I just want an alert when price crosses above the upper band and another for when price crosses below the lower band. I have chart alerts set for these actions, but I can't always be at my computer and I do have to sleep, haha.

Thank you so much for your help!!

input length = 55;
input lookback = 2;
input lookforward = 1;

def HP = high > Highest(high[1], lookback);


def HF = high > Highest(high[-lookforward], lookforward);
def HPc = if HP then 1 else if high == high[1] and HPc[1] then HPc[1] else 0;
def peak = if HPc and HF then high else peak[1];


def LP = low < Lowest(low[1], lookback);
def LF = low < Lowest(low[-lookforward], lookforward);
def LPc = if LP then 1 else if low == low[1] and LPc[1] then LPc[1] else 0;
def trough = if LPc and LF then low else trough[1];


plot upperband = Highest(peak[1], length);
plot lowerband = Lowest(trough[1], length);
Re: Fun with ThinkScript
June 01, 2015 02:19PM
Bijinkei,

This is what I came up with as an alert script. No recursive variables are used. I tested it on a 1 minute chart (just so I wouldn't have to wait as long) and it seemed to work.

This is only the alert for crossing the upper band. I leave the lower band to you.

input length = 55;
input lookback = 2;
input lookforward = 1;

def HP = high > Highest(high[1], lookback);
def HF = high > Highest(high[-lookforward], lookforward);
def HPc = HP or (hp[1] and high == high[1]) or (hp[2] and high == high[1] and high[1] == high[2]);
def peak = if HPc and HF then high else 0;

def upperband = Highest(peak[1], length);
plot alert = close crosses above upperband;

Make sure you change the aggregation period as needed and set it to trigger if true.



- robert


Professional ThinkorSwim indicators for the average Joe



Edited 1 time(s). Last edit at 06/01/2015 02:21PM by robert.
Re: Fun with ThinkScript
June 02, 2015 08:08AM
Robert,

Thank you for your recent reply. I really appreciate the additional time, effort and script you've expended trying to find a solution to the linear regression slope - percentage issue...

As I review the continuing evolution of this issue, I've come to realize I've always been looking for:

1. linear regression (channel) "length" = 100% (just like LinearRegCh100)
2. return the slope of the linear regression (channel)
3. determine if its' value is positive or negative ("angle > 0" or "angle < 0" ) (note: minAngle is a helpful addition)
4. create a condition or filter grouping all positive or all negative values within the result set

5. specify/toggle the selected timeframe/aggregation manually
6. review the final result set

I hope this makes sense...

Off topic...what screen capture utility are you are currently using? I'm guessing Techsmith's SnagIt. If so, would you recommend it?

Thanks again!
Re: Fun with ThinkScript
June 02, 2015 10:18AM
Thank you so much! It works amazingly! Doing the lowerband one tripped me up for a bit until I looked at it a bit and was like NO WONDER! Sometimes it's just the most obvious things that end up being the most frustrating. I actually ended up putting it into a study first so that I could name the study and trim it down to one short and to the point text message rather than 3 out of order messages.
Re: Fun with ThinkScript
June 03, 2015 09:37AM
Quote
netarchitech
Off topic...what screen capture utility are you are currently using? I'm guessing Techsmith's SnagIt. If so, would you recommend it?

You've a good eye for detail. That is exactly the program I am using. Hardly a day goes by that I don't use it. I also like to use ScreenSnapzProX.

Yes, I would recommend SnagIt. I like how easily annotations can be added to a screenshot. A wonderful bonus, for me, is that each annotation is created on a separate layer within the SnagIt editor so they can be edited / deleted later.

Quote
netarchittech
As I review the continuing evolution of this issue, I've come to realize I've always been looking for:

1. linear regression (channel) "length" = 100% (just like LinearRegCh100)

Ok. Just to clarify, the LinearRegCh100 study will calculate the linear regression channel across all of the bars on the currently displayed chart's time frame. So, for a daily, one month chart, LinearRegCh100 would calculate the linear regression channel with a length of 21 days. For a daily, one year chart, the length would be 252 days. This will result in dramatically different linear regression channels and corresponding slopes depending on the chart's length. See screenshot below.

[click for full-size image]


The major obstacle when running a scan to find slopes that meet certain criteria is that the LinearRegCh100 slope will be calculated across all bars and the scanner's look-back period (how far back in time it begins scanning) is unchangeable. As such, the scan results will match up with ONLY one charting time frame. After some testing, I learned that when set to a daily period, the scanner looks back 252 bars (1 market year).

So, if you want to scan for LinearRegCh100 slope and if you have your charts set to daily, one year time frame, then the scan results will be valid. If you have your charts set to anything else, the scan's results will not match up with the displayed charts.

With those limitations in mind, the following scripts may be used to scan daily, one year LinearRegCh100 slopes.

Scanning for positive slopes:

# Scan for positive slopes
# manually change minSlopeAngle before scanning
input minSlopeAngle = 15;
# ---- don't change anything below this line ----
def slope = LinearRegressionSlope(length = 252);
def angle = ATan(slope) * 180 / Double.Pi;
plot signal = angle > 0 and angle >= minSlopeAngle;

Scanning for negative slopes:

# Scan for positive slopes
# manually change minSlopeAngle before scanning
input minSlopeAngle = 15;
# ---- don't change anything below this line ----
def slope = LinearRegressionSlope(length = 252);
def angle = ATan(slope) * 180 / Double.Pi;
plot signal = angle < 0 and AbsValue(angle) >= minSlopeAngle;

The following bit of code may be used as a sortable, custom watchlist column to display the LinearRegCh100 slope angle (again, daily, one year time period).

plot angle = round(atan(linearRegressionSlope(length = 252))*180/double.pi);

- robert


Professional ThinkorSwim indicators for the average Joe



Edited 1 time(s). Last edit at 06/03/2015 09:42AM by robert.
Re: Script Question
June 03, 2015 12:48PM
I plot this script as a line on a chart;

# 5 Cents Below Open #
def OpenNeg5 = (open("period" = AggregationPeriod.DAY) -.05);
plot condition = OpenNeg5;


Does anyone know of a way to re-script it so the line starts 10 candles behind the current candle? Thanks.
Re: Script Question
June 03, 2015 01:06PM
Quote
Ralph53
I plot this script as a line on a chart;

# 5 Cents Below Open #
def OpenNeg5 = (open("period" = AggregationPeriod.DAY) -.05);
plot condition = OpenNeg5;


Does anyone know of a way to re-script it so the line starts 10 candles behind the current candle? Thanks.



# 5 Cents Below Open # 
def OpenNeg5 = (open("period" = AggregationPeriod.DAY) - .05);
def lastbar = HighestAll(if IsNaN(close) then 0 else BarNumber());
plot condition = if BarNumber() < lastbar - 10 then Double.NaN else GetValue(OpenNeg5, BarNumber() - lastbar);

- robert


Professional ThinkorSwim indicators for the average Joe
Re: Fun with ThinkScript
June 04, 2015 10:27PM
I didn't describe this right. I wanted to place the line on the left side of the chart. On a 15 candle chart it would start on the 10th candle from the right and work left from there. I find that to many horizontal lines on a chart become a distraction and it would view better if some were on the left.

I don't know if this can be done as I've never seen a line drawn in this way. It might need that (SetHiding() function) that doesn't work.


If it can be done what would it look like?

# 5 Cents Below Open #
def OpenNeg5 = (open("period" = AggregationPeriod.DAY) - .05);
def lastbar = HighestAll(if IsNaN(close) then 0 else BarNumber());
plot condition = if BarNumber() < lastbar - 10 then Double.NaN else GetValue(OpenNeg5, BarNumber() - last bar);


Thanks.
Re: Fun with ThinkScript
June 04, 2015 10:53PM
Robert,

Thank you for your latest reply. I continue to be very grateful and appreciative for your time, efforts and expertise in our discussion...

Quote
Robert

Quote
netarchitech
Off topic...what screen capture utility are you are currently using? I'm guessing Techsmith's SnagIt. If so, would you recommend it?

You've a good eye for detail. That is exactly the program I am using. Hardly a day goes by that I don't use it. I also like to use ScreenSnapzProX.

Yes, I would recommend SnagIt. I like how easily annotations can be added to a screenshot. A wonderful bonus, for me, is that each annotation is created on a separate layer within the SnagIt editor so they can be edited / deleted later.

Thank you for the compliment smiling smiley Unfortunately, I can't take advantage of ScreenSnapzProX since I'm running a Windows PC. On the upside, SnagIt 12 has video capture built in, so I think that base is covered...

Thank you also for the SnagIt recommendation. Your stamp of approval is enough for me. As for the annotation layering feature, it's not mentioned by Techsmith on the SnagIt website, but it's nice to know it's there...

Regrettably, I haven't been able to dig into the latest information and code you've forwarded in your latest reply, as I am going to be going out of town early in the morning. However, as soon as I get back I'm looking forward to delving into all of it...

Thanks again!
Sorry, only registered users may post in this forum.

Click here to login