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
October 30, 2018 06:11PM
if you love his wolfwave his market structure or hamonics are awesome.
Re: Fun with ThinkScript
October 30, 2018 08:09PM
I definitely want to buy those as well. I would like to add a custom strategy to the wave. Do you know if that’s possible with his Wolfe wave?
Re: Fun with ThinkScript
October 30, 2018 08:19PM
double reply. sorry



Edited 1 time(s). Last edit at 10/30/2018 08:27PM by dyannantuonojr.
Re: Fun with ThinkScript
October 30, 2018 08:26PM
define custom study there are many strategies to use with this indicator. first you should decide how you are going trade the indicator( are you playing the last wave or the 2 last waves) You also have to anticipate which direction the wave is going in. I would start with a momentum indicator and keep refining your process.
Keltner Channels Study
October 28, 2018 10:19AM
Hello everyone!! I am new to register but have been enjoying this forum for well over a year. I am trying to modify a script that uses 2 Keltner channels. I have not been able to parse this study and have it only declare the labels on the top of my screen for kentler channel value and if the trend is above or below said channel. The additional moving averages are not really important. Thanks for your help.


declare weak_volume_dependency;
input showBubble = yes;
input displace = 0;
input factor1 = 1.5;
input factor2 = 3.0;
input length = 26;
input price = close;
input averageType = AverageType.EXPONENTIAL;
input trueRangeAverageType = AverageType.WILDERS;
input showLabel = yes;
input showKBands = yes;
input lineLength = 0;
input showB = yes ;
input BubbleFma = 35;
input Bubblesma = 25;
DefineGlobalColor("upper", Color.dark_green);
DefineGlobalColor("lower", Color.red);
DefineGlobalColor("MA", Color.black);
DefineGlobalColor("Close", Color.blue);
DefineGlobalColor("bubble", Color.cyan);
DefineGlobalColor("upperBubble", Color.green);
DefineGlobalColor("lowerBubble", Color.pink);

def shift1 = factor1 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shift2 = factor2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);


def average = MovingAverage(averageType, price, length);
plot Avg = average;
avg.SetPaintingStrategy(PaintingStrategy.LINE);
avg.SetDefaultColor(GlobalColor("ma"winking smiley);
avg.setLineWeight(2);



plot UpperBand1 = average[-displace] + shift1[-displace];
UpperBand1.SetPaintingStrategy(PaintingStrategy.line);
UpperBand1.SetDefaultColor(GlobalColor("upper"winking smiley);
UpperBand1.setLineWeight(2);

plot UpperBand2 = average[-displace] + shift2[-displace];
UpperBand2.SetPaintingStrategy(PaintingStrategy.line);
UpperBand2.SetDefaultColor(GlobalColor("upper"winking smiley);
UpperBand2.setLineWeight(2);

plot LowerBand1 = average[-displace] - shift1[-displace];
lowerBand1.SetPaintingStrategy(PaintingStrategy.line);
lowerBand1.SetDefaultColor(GlobalColor("lower"winking smiley);
lowerBand1.setLineWeight(2);

plot LowerBand2 = average[-displace] - shift2[-displace];
lowerBand2.SetPaintingStrategy(PaintingStrategy.line);
lowerBand2.SetDefaultColor(GlobalColor("lower"winking smiley);
lowerBand2.setLineWeight(2);


Def ub1 = upperband1;
Def lb1 = lowerband1;
Def ub2 = upperband2;
Def lb2 = lowerband2;
Def ma = average;

def lastBar = !IsNaN(close) && IsNaN(close[-1]);
def lastClose = if lastBar then close else lastClose[1];
def lastub1 = if lastBar then ub1 else lastub1[1];
def lastlb1 = if lastBar then lb1 else lastlb1[1];
def lastub2 = if lastBar then ub2 else lastub2[1];
def lastlb2 = if lastBar then lb2 else lastlb2[1];
def lastma = if lastBar then ma else lastma[1];


plot KLB1 = if IsNaN(close[-lineLength-1]) then lastLB1 else Double.NaN;
KLB1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
KLB1.SetDefaultColor(GlobalColor("lower"winking smiley);
klb1.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastlb1," LB1 ",(GlobalColor("lower"winking smiley), if close > ub1 then yes else no);

plot KUB1 = if IsNaN(close[-lineLength-1]) then lastUB1 else Double.NaN;
KUB1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
KUB1.SetDefaultColor(GlobalColor("upper"winking smiley);
KUB1.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastub1," UB1 ",(GlobalColor("Upper"winking smiley), if close < ub1 then yes else no);

plot KLB2 = if IsNaN(close[-lineLength-1]) then lastLB2 else Double.NaN;
KLB2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
KLB2.SetDefaultColor(GlobalColor("lower"winking smiley);
klb2.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastlb2," LB2 ",(GlobalColor("lower"winking smiley),no);

plot KUB2 = if IsNaN(close[-lineLength-1]) then lastUB2 else Double.NaN;
KUB2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
KUB2.SetDefaultColor(GlobalColor("upper"winking smiley);
KUB2.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastub2," UB2 ",(GlobalColor("Upper"winking smiley),if close < ub2 then yes else no);


plot KMA = if IsNaN(ma[-lineLength-1]) then lastMA else Double.NaN;
KMA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
KMA.SetDefaultColor(GlobalColor("MA"winking smiley);
kma.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastma," MA ",(GlobalColor("bubble"winking smiley),yes);


plot clPrice = if IsNaN(close[-lineLength-1]) then lastClose[-lineLength] else Double.NaN;
clPrice.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
clPrice.SetDefaultColor(GlobalColor("close"winking smiley);
clPrice.setLineWeight(2);
addchartbubble( IsNaN(close[-lineLength-1]) and lastBar and showb,lastclose," Close ",(GlobalColor("close"winking smiley), if close > lb1 then yes else no );

AddLabel(showLabel, " Keltner = (" + length + "winking smiley " +
" (" + factor1 + "winking smiley " + " UB = (" + Round( ub1, 1) + "winking smiley " + " LB = (" + Round(lb1, 1) + "winking smiley " + " MA = (" + round(kma,1) + "winking smiley " , if close > average then Color.dark_GREEN else if close < average then Color.RED else if close > ub1 or close < lb1 then Color.ORANGE else color.black);

AddLabel(showLabel, " Keltner = (" + length + "winking smiley " +
" (" + factor2 + "winking smiley " + " UB2 = (" + Round( ub2, 1) + "winking smiley " + " LB2 = (" + Round(lb2, 1) + "winking smiley ", if close > average then Color.dark_GREEN else if close < average then Color.RED else if close > ub2 or close < lb2 then Color.ORANGE else color.black);





Def Alert = close > ub2 or close < lb2;
alert(alert, " Price extreme alert! ", alert.BAR, sound.Ring);
Re: Fun with ThinkScript
October 31, 2018 05:12AM
I’m sorry I’ll clrify. I made a custom strategy using a few other waves and profit margin that I would like to add to the script. Basically it would show up when a moves in the Wolfe wave showed up
Re: Center of Gravity
October 31, 2018 11:12AM
Optiontrader101, I just read your post "Center of Gravity" (only 4 years later smiling smiley)

Have you found a solution for the re-painting problem?

Thanks

Amir



Edited 1 time(s). Last edit at 10/31/2018 01:34PM by amir.
Re: Fun with ThinkScript
October 31, 2018 04:53PM
can you share the script? I may have a solution I have been playing with using %
Re: Fun with ThinkScript
November 01, 2018 10:17AM
Hello everyone,

I would like to know if someone could give me some idea about how to implement a scan for stocks that made a 20 bar low at any point during the last 5 bars?

So if it made a 20 bar low today, or yesterday and so on up to 5 bars it would match the criteria

Thanks and Regards,
Isaac
Re: Fun with ThinkScript
November 17, 2018 02:46PM
Hello,

I first want to say that this site is incredible! There is so much knowledge and people willing to share their knowledge and I am so happy that I found y'all. I am wondering if anyone can help me (I know Robert doesnt post here anymore) with the following code. I am trying to get labels on every one of my charts that shows the current IWM price and colors it green if IWM is greater than IWM's close from the previous day and red if IWM is less than IWM's close from the previous day. Thank you in advance.

#IWM label
def IWM = close("IWM"winking smiley;

AddLabel(IWM > close("IWM", close(period="DAY"winking smiley)[1], "IWM: " + IWM, Color.GREEN);
AddLabel(IWM < close(”IWM”, close(period="DAY"winking smiley)[1], "IWM: " + IWM, Color.LIGHT_RED);
Re: Fun with ThinkScript
November 18, 2018 10:21PM
Hi all,
i am new to thinkscript and have a quick question about starting to code an indicator that plots the "price percentage change" of a symbol as a line on a lower study. i want it to plot the price percentage change between the symbol's current value and it's prior day's close. on a TOS chart it is just right of the symbol's current price and just under it's value change from the prior day's close. for example on the SPY it is currently +0.26% at the close on 11-16-2018. i also want to be able to change the symbol being plotted inside the indicator. in the code below the price1 is supposed to be the prior day's close. price2 is current bars close.
please see image.
any help would be greatly appreciated.
Thanks


here is what i have so far:

declare lower;

#Symbol Input
input SYMB1 = “SPY”;

input price1 = close - 1;
input price2 = close;

plot PercentChg = ((price1 - price2) / price2) * 100;






Edited 1 time(s). Last edit at 11/18/2018 10:24PM by Hawkeye.
Re: Fun with ThinkScript
November 20, 2018 12:47AM
Can anyone help me with this code? I am getting two different values for the opening 5 min range and the "entry" line on the 5 min and 2 min charts

# 5 min opening range
# Robert Payne

def OpenRangeMinutes = 5;
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;
plot OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;

OpenRangeHigh.SetStyle(Curve.SHORT_DASH);
OpenRangeHigh.SetDefaultColor(Color.YELLOW);
OpenRangeHigh.SetLineWeight(1);
OpenRangeLow.SetStyle(Curve.SHORT_DASH);
OpenRangeLow.SetDefaultColor(Color.YELLOW);
OpenRangeLow.SetLineWeight(1);

# Plot 5 min entry line
def first30 = if SecondsFromTime(0930) >= 0 and SecondsTillTime(1000) > 0 then 1 else 0;
def dailyRange = high(period="day" )[1] - low(period="day" )[1];
def range = average(dailyrange,10);

plot entryLine1 = if first30 then openrangehigh + (range * 0.03) else double.nan;
entryline1.setdefaultcolor(color.green);
entryline1.setpaintingStrategy(paintingStrategy.HORIZONTAL);

plot entryLine2 = if first30 then openrangelow - (range * 0.03) else double.nan;
entryline2.setdefaultcolor(color.green);
entryline2.setpaintingStrategy(paintingStrategy.HORIZONTAL);

def SoundAlert = high crosses above entryLine1 or low crosses below entryLine2;
Alert(SoundAlert, "Something exciting just happened with " + GetSymbol(), Alert.BAR, Sound.Ring);
5 min range
November 28, 2018 03:42PM
Quote
F1p 0pt10ns
"Can anyone help me with this code? I am getting two different values for the opening 5 min range and the \"entry\" line on the 5 min and 2 min charts"

You didn't say what the problem actually is. I imagine that you see in some charts that the range shown, varies depending on the chart time frame (5 min. vs 2 min)...

If that is the case, there is nothing wrong, your 5 min chart or 1 min chart shows the right 5 min range because the code def OpenRangeMinutes = 5; is for 5 min charts. In one min chart, that is simple the range of the first 5 bars BUT if you set a 2 min charts the range 5 min is actually 2 and a half bars !, that is not possible to show, so what you see is the range of the first 3 bars= 6 min.

Hope it helps



Edited 1 time(s). Last edit at 11/28/2018 04:30PM by rigel.
Re:"price percentage change"
November 28, 2018 03:54PM
Hawkeye

Not sure what you try to achieve plotting one horizontal line with a very low value (e.g 0.81%) rather than write it in a label


See my post here to see if it gives you ideas



Edited 1 time(s). Last edit at 11/28/2018 03:55PM by rigel.
Re: IWM labels
November 28, 2018 04:26PM
Quote
F1p 0pt10ns
I am trying to get labels on every one of my charts that shows the current IWM price and colors it green if IWM is greater than IWM's close


You were very close, replace your add labels with these:

AddLabel(IWM > close("IWM","DAY" )[1], "IWM: " + IWM, Color.GREEN);
AddLabel(IWM < close("IWM","DAY" )[1], "IWM: " + IWM, Color.LIGHT_RED);

Re: Keltner Channels Study
December 01, 2018 05:54AM
Quote
dyannantuonojr
I have not been able to parse this study and have it only declare the labels ...

What do you mean? did you copy that code with those winking smiles and you have errors? it works well for me.



Edited 1 time(s). Last edit at 12/06/2018 09:18AM by rigel.
Re: Fun with ThinkScript
December 01, 2018 02:35PM
Hi,

I was wondering if anyone had Roberts Rising Tide Indicator? I searched the forum and the links to it no longer worked.

I have purchased some of Roberts Indicators and love all of them...they have become my favorites and I think the Rising Tide would complement the reversal strategy that I trade.

If anyone can help me out, it would be much appreciated.
Thanks!
Re: Re:"price percentage change"
December 03, 2018 08:47PM
thanks rigel,

ok so, how can i add an "any symbol" input to "rigel's" code below so that i could be looking at one chart and then add this percentage label of another symbol to same chart? like

input Symbol = “SPY”;

************

# % Price change vs Day's Opening
# by Rigel 2018

def agg=aggregationPeriod.DAY;
def price = close;
def opening= Open(period=agg);
def PercentChg = 100 * (price / opening-1);

AddLabel(yes, Concat("%change = ", Round(percentchg, 2)), if percentchg <0 then Color.RED else if percentchg >0 then color.GREEN else color.white);

***********

Thanks to anyone who can please help
Re: Re:"price percentage change"
December 05, 2018 04:03PM
Quote
Hawkeye
ok so, how can i add an "any symbol" input

Please read my answer to F1p 0pt10ns, in this page, about getting IWM in any other symbol chart or my other post here



Edited 1 time(s). Last edit at 12/05/2018 04:08PM by rigel.
Re: Fun with ThinkScript
December 13, 2018 06:36PM
Hey all,

Does anyone have a script that draws the trend lines onto the CCI Indicator?

Thanks!
Balance of Power
December 14, 2018 10:21AM
TC2000 has a Balance of Power indicator. Has anyone converted this BOP indicator for thinkorswim?
Thanks
Re: Fun with ThinkScript
December 15, 2018 08:31AM
I have a lot of good additional ideas for indicators already available on different platforms, but first I want to know is there anyone here serious about doing some code ? Starting to think this side of the forum is dead.
Re: Fun with ThinkScript
December 15, 2018 08:05PM
Hey Robert,

Do you know of such code that exists or possible to create where it would plot horizontal lines at locations with the most occurrences of opens, highs, lows, and closes? Instead of manual drawing these lines for every ticker, I'd like to see if any indicator can be created so that the lines can be automatically drawn for a specific time-frame, example last whole week or last whole year with the most occurrences at specific spots. I'm willing to pay for the coded if need be, please let me if this is possible.

Thank You!
Re: Balance of Power
December 16, 2018 06:30AM
mpetry, is this what you are talking about?

Quote

The Balance of Power indicator measures the market strength of buyers against sellers by assessing the ability of each side to drive prices to an extreme level. The calculation is: Balance of Power = (Close price – Open price) / (High price – Low price) The resulting value can be smoothed by a moving average.

That sudy is already available in TOS under the name BalanceOfMarketPower
Re: Fun with ThinkScript
January 01, 2019 10:14PM
Charles,
I was just looking over some of the old thinkscript posts and happen to see this one from sept. 2016.
I am interested in cycles and noticed in your chart you have some type of cycle lines?
What I was wondering is:
Are all of these done with thinkorswim thinkscript?
Can you explain, what this is and how you do it in thinkscript?
If possible I would like to know more about this.
I am mainly interested in doing something like this on daily and weekly charts.

Also if anyone else here that knows about this type of stuff as far as cycles and finding different cycles etc. using thinkscript,
I would like to hear from you and learn more about it.

Any info or help would be great.
Thanks,
Re: Fun with ThinkScript
January 02, 2019 06:11AM
styx Wrote:
-------------------------------------------------------
> Charles,
> I was just looking over some of the old
> thinkscript posts and happen to see this one from
> sept. 2016.
> I am interested in cycles and noticed in your
> chart you have some type of cycle lines?
> What I was wondering is:
> Are all of these done with thinkorswim
> thinkscript?
> Can you explain, what this is and how you do it
> in thinkscript?
> If possible I would like to know more about this.
>
> I am mainly interested in doing something like
> this on daily and weekly charts.
>
> Also if anyone else here that knows about this
> type of stuff as far as cycles and finding
> different cycles etc. using thinkscript,
> I would like to hear from you and learn more about
> it.
>
> Any info or help would be great.
> Thanks,




Most Traders would never think outside the box on this subject, especially about indicators that are built based on Space & Time. You could start by soaking up the original information on the subject with a few books written by the one and only John F. Ehlers
Re: Fun with ThinkScript
January 09, 2019 02:35AM
Hi Robert,

I'm stuck with the following script. (the "plot" and "if...condition" lines went wrong), I can't get them right to work, therefore, could you help me correct my script? I want to draw a Moving Average that changes/maintains its slope based on the Moving Average, Price, and ATR (Average True Range). Thanks a million!

input price = close;
input length = 9;
input displace = 0;
input averageType = AverageType.SIMPLE;
input ATRpediod = 9;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), ATRperiod);

def avg = MovingAverage(averageType, price, length);

def height = ATR - ATR[1];

def “Angle, deg” = Atan(height/length) * 180 / Double.Pi;

def MovingAverage = Average(price[-displace], length);

if (avg > avg[9]) and (price - price[9]) > ATR then Angle, deg >0, plot MovingAverageSlope;

if (avg > or < avg[9]) and (price - price[9]) < ATR then Angle, deg =0, plot MovingAverageSlope;


-----------------------------------------------------------------------------------------------------------------------------------------------------

Human readable text for the above "plot" line is as follows:↓↓↓

If the current price of the moving average is higher than the price of the moving average 9-periods back, by more than the ATR n-periods back, the slope is considered positive.

If the current price of the moving average is higher or lower than the price of the moving average n-periods back, but their distance is less than the ATR n-periods back, the slope is considered horizontal.

••The Moving Average Slope is calculated by detecting the moving average level n-periods ago and comparing it with the current moving average level. This way, the trend of the moving average can be drawn on the moving average line. This can compare the slopes of two moving averages (fast and slow).

••The slope is calculated by subtracting the price of the moving average n periods ago from the current price of the moving average.
••The slope line on top of such Moving Average is then classified "upwards", downwards, or horizontal) based on the average true range (ATR) n-periods back.
------------------------------------------------------------------------------------------------------------------------------------------------
Inputs

• Period1: The period1 of the MA1.
• Period2: The period2 of the MA2.
• Shift: The number of periods to shift the MA.
• Applied Price: The candlestick price level to be used for MA calculations.
• Slope: The number (n) of periods to look back for slope calculation.
• ATR Period: The Average True Range period to be used for slope classification.



Edited 7 time(s). Last edit at 01/09/2019 09:43AM by sumihiko.
Re: Plot conditions
January 09, 2019 06:03AM
Hi sumihiko

Try this:
input price = close;
input length = 9;
input displace = 0;
input averageType = AverageType.SIMPLE;
input ATRperiod = 9;
declare lower;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), ATRperiod);
addlabel(yes,"atr :"+atr,color.yellow);
def avg = MovingAverage(averageType, price, length);
addlabel(yes,"avg :"+avg,color.white);
def height = ATR - ATR[1];
addlabel(yes,"height :"+height,color.red);
def “Angle, deg” = Atan(height/length) * 180 / Double.Pi;
addlabel(yes,"angle :"+  “Angle, deg”,color.green);
def MovingAverage = Average(price[-displace], length);

#If the current price AND the moving average is higher than the price of the moving average 9-periods back, by more than the ATR n-periods back, the slope is considered positive.

Plot slopepos= if avg > avg[9] and price - price[9] > ATR then “Angle, deg” else double.naN;

#If the current price AND the moving average is higher or lower than the price of the moving average n-periods back, but their distance is less than the ATR n-periods back, the slope is considered horizontal.

Plot slopeflat= if avg != avg[9] and absvalue(price - price[9]) < ATR then “Angle, deg” else double.naN;
slopepos.setdefaultColor(color.green) ;
slopeflat.setdefaultColor(color.red) ;
Re: Plot conditions
January 09, 2019 08:00PM
Thanks Rigel (a million)!
COLOR of slope 3-period later doesn't turn green/red
January 09, 2019 09:16PM
Hi Robert / Rigel.

I am stuck with the color line for SLOPE 3-period ahead (not back) won't turn to green if the current price is greater than the SLOPE 3-consecutive period ahead (not back), it only shows the current SLOPE is green when the current price is greater than the current SLOPE. (e.g.: current price is $10, which is greater than the current SLOPE at $8 then the color of current SLOPE line is green, yet the SLOPE for 1~3 period later(ahead not back) is under $8 but they don't turn green.

Does anyone can help me make the color of SLOPE 3-period later (1st, 2nd, 3rd-period) turn green(or red) if the current price is greater(less) than the SLOPE 3-period ahead (later)? Thanks a million!

------------------------------------------------------------------------------------------------------------------------
input price=close;

declare upper;
plot SLOPE = 2*close[3] - close[9];
SLOPE.AssignValueColor(if price[0] > SLOPE[0], price[0] >SLOPE[-1], price[0] >SLOPE[-2], price[0] >SLOPE[-3] then CreateColor(0, 153, 0) else CreateColor(153, 0, 51));



Edited 8 time(s). Last edit at 01/19/2019 11:03PM by sumihiko.
Sorry, only registered users may post in this forum.

Click here to login