Re: Fun with ThinkScript March 06, 2015 03:57AM |
Registered: 10 years ago Posts: 615 |
Quote
danyzuko
Just wondering, can you tweak it to draw lines based on the body of the candle instead of the absolute end of it?
Price lows and highs seem to be converging at the edge of the body of the candle and not so much the tail.
# Plot areas of potential support / resistance based on major peaks and valleys. # This version plots lines based on candle bodies rather than the wicks. # Changing "magnitude" determines the granularity of detected peaks or valleys. # A low magnitude value will plot minor price swings, while a high magnitude value # will only plot major price swings. # A magnitude value of 2 means that a bodytop must be greater than the 2 candles # before and after it to be considered a peak. Likewise for the bodybottoms to be a valley. # # Robert Payne input magnitude = 5; # define top and bottom of candle body def bodytop = max(open, close); def bodybottom = min(open, close); # define and plot the most recent peak def peak = bodytop >= Highest(bodytop[1], magnitude) and bodytop >= Highest(bodytop[-magnitude], magnitude); def peakvalue = if BarNumber() < magnitude then Double.NaN else if peak then bodytop else peakvalue[1]; plot peakline = peakvalue; peakline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); peakline.SetDefaultColor(Color.GREEN); # extend the current peak line to the right edge of the chart def countp = if IsNaN(peak) and !IsNaN(peak[1]) then 1 else countp[1] + 1; plot peakext = if IsNaN(peak) then GetValue(peakline, countp) else Double.NaN; peakext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); peakext.SetDefaultColor(Color.GREEN); # continue the previous peak as a dashed line def oldpeak = if BarNumber() < magnitude then Double.NaN else if peak then peakvalue[1] else oldpeak[1]; plot oldpeakline = oldpeak; oldpeakline.SetPaintingStrategy(PaintingStrategy.DASHES); oldpeakline.SetDefaultColor(Color.GREEN); # define and plot the most recent valley def valley = bodybottom <= Lowest(bodybottom[1], magnitude) and bodybottom <= Lowest(bodybottom[-magnitude], magnitude); def valleyValue = if BarNumber() < magnitude then Double.NaN else if valley then bodybottom else valleyValue[1]; plot valleyline = valleyValue; valleyline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); valleyline.SetDefaultColor(Color.PINK); # extend the current valley line to the right edge of the chart def countt = if IsNaN(valley) and !IsNaN(valley[1]) then 1 else countt[1] + 1; plot valleyext = if IsNaN(valley) then GetValue(valleyline, countt) else Double.NaN; valleyext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); valleyext.SetDefaultColor(Color.PINK); # continue the previous valley as a dashed line def oldvalley = if BarNumber() < magnitude then Double.NaN else if valley then valleyValue[1] else oldvalley[1]; plot oldvalleyline = oldvalley; oldvalleyline.SetPaintingStrategy(PaintingStrategy.DASHES); oldvalleyline.SetDefaultColor(Color.PINK);
Re: Fun with ThinkScript March 08, 2015 01:33AM |
Registered: 9 years ago Posts: 7 |
Re: Fun with ThinkScript March 08, 2015 08:12AM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript March 09, 2015 08:09AM |
Registered: 9 years ago Posts: 60 |
Re: Fun with ThinkScript March 15, 2015 01:54AM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript March 15, 2015 06:09AM |
Registered: 10 years ago Posts: 615 |
Quote
Gaterz
I'm having a problem with the AddLabel. This bit of code has the label always visible regardless if the conditions are met or not. Only want it showing if the Chop conditions are met. Can't find my error.
Help?
def chop = "DI+" < level_1 and "DI-" < level_1 and ADX < level_1;
def chop = plusDM < level_1 and minusDM < level_1 and ADX < level_1;
Re: Fun with ThinkScript March 19, 2015 07:37AM |
Registered: 12 years ago Posts: 321 |
Re: Fun with ThinkScript March 19, 2015 11:32AM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript March 19, 2015 12:22PM |
Registered: 10 years ago Posts: 615 |
Quote
mtut
Any one know if it is possible to create a signal based on the hi \ low bubbles on the chart?
def alert = close > highestall(high[1]);
Re: Fun with ThinkScript March 19, 2015 12:39PM |
Registered: 9 years ago Posts: 31 |
Re: Fun with ThinkScript March 19, 2015 08:55PM |
Registered: 12 years ago Posts: 321 |
Re: Fun with ThinkScript March 20, 2015 09:30AM |
Registered: 9 years ago Posts: 13 |
Re: Fun with ThinkScript March 20, 2015 01:06PM |
Registered: 9 years ago Posts: 13 |
Re: Fun with ThinkScript March 24, 2015 02:43PM |
Registered: 10 years ago Posts: 615 |
Quote
from a PM
Hi Robert,
Can you write a code that will mark the high and low of a stock with a option of setting the time period( 5,7,10 days prior )also,having the lines extend through the current trading day?
Re: Fun with ThinkScript March 24, 2015 09:06PM |
Registered: 9 years ago Posts: 11 |
Re: Fun with ThinkScript March 25, 2015 08:32PM |
Registered: 10 years ago Posts: 615 |
Quote
stefonk
Is there a way that I can use this study as a scan to get symbols that
"close crosses above swing high or
"close crosses below swing low.
input swing_back = 8; input swing_forward = 2;
def sb = swing_back; def sf = swing_forward;
def lfor = Lowest(low, sf)[-sf]; def lback = Lowest(low, sb)[1]; def swinglow = if low < lfor and low <= lback then 1 else 0;
def lfor = Lowest(low, 2)[-2];
def lback = Lowest(low, 8)[1];
def swinglow = if low < lfor and low <= lback then 1 else 0;
Re: Fun with ThinkScript March 26, 2015 02:27PM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript March 26, 2015 03:14PM |
Registered: 10 years ago Posts: 615 |
Quote
TraderJoe
Anyone that know how I can get the ATR in percent of the underlying price (last)? Just a simple ATR/LAST. I want it so I can sort my watchlist by biggest movers when there isnt any IV to go on.
plot data = 100 * atr(14).atr / close;
Re: Fun with ThinkScript March 27, 2015 08:03AM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript March 28, 2015 08:19AM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript March 28, 2015 10:08AM |
Registered: 10 years ago Posts: 615 |
Quote
GaryF
I want to know if it is possible to color the background just for crossover bar when one indicator crosses the other. (Ex. 50 SMA crosses 200 SMA). I have tried just about everything I can think of. ...but can not figure crossover.. Any help would be greatly appreciated. Thanks Gary
def sma10 = avarage(close, 10); def sma50 = average(close, 50); def SignalUP = if sma10[1] < sma50[1] and sma10 > sma50 then 1 else 0;
def SignalUP = sma10 crosses above sma50;
AssignBackgroundColor(Color.BLUE);
def yHigh = high(period = "day" )[1]; def yLow = low(period = "day" )[1]; AssignBackgroundColor(if close > yHigh then Color.GREEN else if close < yLow then Color.RED else Color.CURRENT);
A TOS Squeeze WatchList March 28, 2015 09:10PM |
Registered: 9 years ago Posts: 8 |
Re: A TOS Squeeze WatchList March 28, 2015 10:42PM |
Registered: 9 years ago Posts: 8 |
Re: A TOS Squeeze WatchList March 28, 2015 10:52PM |
Registered: 9 years ago Posts: 8 |
Re: A TOS Squeeze WatchList March 28, 2015 11:50PM |
Registered: 10 years ago Posts: 615 |
Quote
mdtmn8888
PS how do I attach an image? thanks
Re: A TOS Squeeze WatchList March 29, 2015 04:10AM |
Registered: 9 years ago Posts: 8 |
Re: A TOS Squeeze WatchList March 29, 2015 04:31AM |
Registered: 9 years ago Posts: 8 |
Re: Fun with ThinkScript March 29, 2015 04:33AM |
Registered: 9 years ago Posts: 8 |
Re: Fun with ThinkScript March 29, 2015 04:41AM |
Registered: 9 years ago Posts: 8 |
Re: Fun with ThinkScript March 29, 2015 07:41AM |
Registered: 9 years ago Posts: 2 |