Re: Fun with ThinkScript August 05, 2014 02:24PM |
Registered: 9 years ago Posts: 6 |
Re: Fun with ThinkScript August 05, 2014 10:26PM |
Registered: 9 years ago Posts: 8 |
# TS_GapFill # [www.thinkscripter.com] # thinkscripter@gmail.com # Last Update 28 Jan 2010 input marketOpenTime = 0930; input marketCloseTime = 1615; def yesterdaysClose = close(period = "DAY" )[1]; def secondsFromOpen = secondsFromTime(marketOpenTime); def secondsTillClose = secondsTillTime(marketCloseTime); def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0; rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen[1] < 0) or (getDay() != getDay()[1]) then open else regularHoursOpen[1]; def newDay = if getDay() != getDay()[1] then 1 else 0; rec regHoursHigh = if newDay then high else if marketOpen then if high > regHoursHigh[1] then high else regHoursHigh[1] else high; rec regHoursLow = if newDay then low else if marketOpen then if low < regHoursLow[1] then low else regHoursLow[1] else low; def yc = if marketOpen then yesterdaysClose else double.nan; def o = if marketOpen then regularHoursOpen else double.nan; def hg = o + (yc - o) / 2; def gapUp = if yc < o then 1 else 0; def gapDown = if yc > o then 1 else 0; def gapRemaining = if gapUp then Max(regHoursLow - yc, 0) else if gapDown then Max(yc - regHoursHigh, 0) else 0; def percentRemaining = 100 * gapRemaining / AbsValue(yc - o); def gapFilled = if percentRemaining == 0 then 1 else 0; def halfGapFilled = if percentRemaining <= 50 then 1 else 0; plot gH = if (gapUp and !gapFilled and marketOpen and !newDay[-1]) then regHoursLow else if (gapDown and !gapFilled and marketOpen and !newDay[-1]) then yc else double.nan; plot gL = if (gapUp and !gapFilled and marketOpen and !newDay[-1]) then yc else if (gapDown and !gapFilled and marketOpen and !newDay[-1]) then regHoursHigh else double.nan; plot hGF = if !gapFilled and !halfGapFilled and marketOpen and !newDay[-1] then hg else double.nan; gH.SetPaintingStrategy(paintingStrategy.DaSHES); gH.AssignValueColor(if gapDown then color.darK_red else color.dark_green); gL.SetPaintingStrategy(paintingStrategy.DASHES); gL.AssignValueColor(if gapDown then color.darK_red else color.dark_green); hGF.setStyle(curve.LONG_DASH); hGF.SetDefaultColor(color.dark_gray); gH.hideBubble(); gL.hideBubble(); hgF.hideBubble(); AddCloud(gH, gL, color.gray, color.gray); #AddChartLabel(gapUp or gapDown, concat(percentRemaining, " % Gap Remaining" ), color.white);
Re: Fun with ThinkScript August 07, 2014 01:40PM |
Registered: 9 years ago Posts: 6 |
Re: Fun with ThinkScript August 07, 2014 03:36PM |
Registered: 10 years ago Posts: 615 |
Quote
mklatx
1) In short, I would like to add a label that simply lists the RSI Wilder with colors depending on level ( over/under 70/30 and one in between ). I'd also like to have it just say RSI and the number. I know there is a way to do it but I think this rsi wilder is confusing me. or maybe its the code I am just not getting. Also, I am not sure if its best to specify the rsi period etc but you probably have an idea.
def RSI = RSIWilder(length = 14).RSI; AddLabel(yes, "RSI: " + Round(RSI, 2), if RSI > 70 then Color.PINK else if RSI < 30 then Color.LIGHT_GREEN else Color.YELLOW);
Re: Fun with ThinkScript August 07, 2014 03:46PM |
Registered: 10 years ago Posts: 615 |
Quote
mklatx
3) also, is there a way to have a label that shows the % of volume today based on the past days AT THAT POINT IN DAY? Not sure if that is possible.
Quote
mklatx
4) is there a way to add a label that gives relative performance to a specified index? ie Facebook is up 1% relative to /NQ
def sym = "/NQ"; def price = close(sym); # returns the closing price of "/NQ" for the current candle def price1 = close(sym, period = "day" )[1]; # returns yesterday's closing price for "/NQ"
Re: Fun with ThinkScript August 08, 2014 07:50AM |
Registered: 9 years ago Posts: 6 |
Re: Fun with ThinkScript August 08, 2014 08:19AM |
Registered: 10 years ago Posts: 615 |
Quote
mklatx
On the RSI, I am having trouble adding the input for the length so I can make it variable
input avgLength = 10; plot movingAverage = average(close, avgLength);
input RSIlength = 14; def RSI = RSIWilder(length = RSIlength).RSI;
Quote
mklatx
I was also wondering if there was a way to have it show maybe the 14 day rsi even when I am on a 5 minute chart. I am not sure if that is possible though.
def RSI = RSIWilder(length = 14, price = close(period = "day" )).RSI;
Re: Fun with ThinkScript August 08, 2014 08:55PM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript August 08, 2014 10:18PM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript August 09, 2014 06:06AM |
Registered: 10 years ago Posts: 615 |
Quote
Bentley
Hi Guys,
I'm having some trouble with some code. I'm trying to do a scan to look for
2-day RSI falls 3days in a row (inclusive).
Here is my code:
def RSI2 = RSIWilder(length = 2, threshold = 10);
def RSI20 = RSI2[0];
def RSI21 = RSI2[1];
def RSI22 = RSI2[2];
def RSI23 = RSI2[3];
RSI2.1 > RSI2.1.1 > RSI2.1.2 > RSI2.1.3 > RSI2.1.4;
But the code can't run...anyone any idea..confused smiley
Thousands thank.
def RSI2 = RSIWilder(length = 2).RSI; def RSIfall = RSI2 < RSI2[1]; plot signal = RSIfall and RSIfall[1] and RSIfall[2];
Re: Fun with ThinkScript August 09, 2014 06:31AM |
Registered: 10 years ago Posts: 615 |
Quote
Gaterz
So what this is supposed to be is to look for long bodied candles (candles longer than the previous 3 candles( this part seems to work fine)), who's body do NOT overlap the body of the previous candle. So they can share an open/close but that's it. Some of the candles on mine are overlapping, some aren't. Can you help?
Re: Fun with ThinkScript August 09, 2014 12:36PM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript August 10, 2014 01:44PM |
Registered: 9 years ago Posts: 2 |
Re: Fun with ThinkScript August 11, 2014 03:35PM |
Registered: 12 years ago Posts: 321 |
Re: Fun with ThinkScript August 11, 2014 05:44PM |
Registered: 10 years ago Posts: 615 |
Quote
mtut
Per Darcy's posting of her Qchart setup, I noticed that my TOS MoneyFlow set at 13 does not match hers. Anyone have an idea on how to reduce the smoothness?
Re: Fun with ThinkScript August 11, 2014 09:43PM |
Registered: 12 years ago Posts: 321 |
Re: Fun with ThinkScript August 14, 2014 07:16AM |
Registered: 10 years ago Posts: 27 |
# DMI def DIr = DIPlus(5); def DIg = DIMinus(5); def C4 = if (DIr[0] > DIg[0] AND DIr[1] < DIg[1]) then 1 else if (DIr[0] < DIg[0] AND DIr[1] > DIg[1]) then -1 else 0;
Re: Fun with ThinkScript August 14, 2014 07:40AM |
Registered: 10 years ago Posts: 615 |
Quote
dynamike
Hey Robert,
Your FP/HRFP Scan Query works great.
Is there a way I can add some code below your "# DMI" section so that it detects when either the indicators cross OR:
- The red line is below 10 and crosses above 10 (For UP moves)
- The green line is below 10 and crosses above 10 (For DOWN moves)
def C4 = if (DIr crosses above DIg) or (DIr crosses above 10) then 1 else if (DIR crosses below DIg) or (DIg crosses above 10) then -1 else 0;
Re: Fun with ThinkScript August 15, 2014 12:39PM |
Registered: 9 years ago Posts: 6 |
Re: Fun with ThinkScript August 21, 2014 09:23AM |
Registered: 9 years ago Posts: 16 |
Re: Fun with ThinkScript August 21, 2014 10:32AM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript August 21, 2014 12:31PM |
Registered: 9 years ago Posts: 16 |
Re: Fun with ThinkScript August 21, 2014 01:56PM |
Registered: 10 years ago Posts: 615 |
Quote
meyer99
Robert,
Yes I have seen them. Not what I am looking for. It only has an average, with no indication of the length.
I would like to see individual years and an average that I understand what is averaging.
Thank you in advance.
Adrian
plot ThisYear = close; plot LastYear = close[252]; plot TwoYearsAgo = close[2*252];
Re: Fun with ThinkScript August 21, 2014 02:22PM |
Registered: 9 years ago Posts: 16 |
Re: Fun with ThinkScript August 21, 2014 03:48PM |
Registered: 10 years ago Posts: 615 |
Quote
meyer99
I think it works. Can you show me how to do the average?
Is it possible to replace the price bubble on the right with a label for each line?
Thank you.
Adrian
input AvgLength = 20; plot ThisYear = Average(close, AvgLength); ThisYear.SetDefaultColor(Color.CYAN); plot LastYear = Average(close[252], AvgLength); LastYear.SetDefaultColor(Color.PINK); plot TwoYearsAgo = Average(close[2 * 252], AvgLength); TwoYearsAgo.SetDefaultColor(Color.LIGHT_ORANGE); def today = GetLastDay() == GetDay(); AddChartBubble(today, ThisYear, "This Year", Color.CYAN); AddChartBubble(today, LastYear, "Last Year", Color.PINK); AddChartBubble(today, TwoYearsAgo, "Two Years Ago", Color.LIGHT_ORANGE);
Re: Fun with ThinkScript August 21, 2014 04:15PM |
Registered: 9 years ago Posts: 16 |
Re: Fun with ThinkScript August 21, 2014 04:21PM |
Registered: 10 years ago Posts: 615 |
Quote
meyer99
I was just looking for the average of this year, last year, and two years ago. So the average of the different data series.
I think the ones you gave me are average of 20 days inside a specific year right?
plot ThisYear = close; ThisYear.SetDefaultColor(Color.CYAN); plot LastYear = close[252]; LastYear.SetDefaultColor(Color.PINK); plot TwoYearsAgo = close[2*252]; TwoYearsAgo.SetDefaultColor(Color.LIGHT_ORANGE); plot CombinedAvg = (ThisYear + LastYear + TwoYearsAgo) / 3; CombinedAvg.SetDefaultColor(Color.YELLOW); def today = GetLastDay() == GetDay(); AddChartBubble(today, ThisYear, "This Year", Color.CYAN); AddChartBubble(today, LastYear, "Last Year", Color.PINK); AddChartBubble(today, TwoYearsAgo, "Two Years Ago", Color.LIGHT_ORANGE);
Re: Fun with ThinkScript August 21, 2014 04:25PM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript August 21, 2014 04:31PM |
Registered: 9 years ago Posts: 16 |
Re: Fun with ThinkScript August 21, 2014 04:35PM |
Registered: 9 years ago Posts: 16 |