Re: Fun with ThinkScript March 25, 2018 11:31AM |
Registered: 6 years ago Posts: 33 |
five min aggregation period March 25, 2018 11:33AM |
Registered: 6 years ago Posts: 33 |
Re: Fun with ThinkScript April 08, 2018 11:49AM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 08, 2018 11:57AM |
Registered: 6 years ago Posts: 33 |
Re: Fun with ThinkScript April 08, 2018 03:09PM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 09, 2018 04:18PM |
Registered: 8 years ago Posts: 7 |
##GW RSI input over_bought = 80; input half_way = 50; input over_sold = 20; def trin_c = close("$TRIN" def trin_cSP = close("$TRINSP" def trin_cNAS = close("$TRIN/Q" ## GW RSI def RSI = reference RSI(length = 13).RSI; def highestRSI = Highest(RSI, 21); def lowestRSI = Lowest(RSI, 21); def RSIS = 100 * (RSI - lowestRSI) / (highestRSI - lowestRSI); def "%K" = Average(RSIS, 3); def "%D" = Average("%K", 5); ##END GW RSI ##TD RSI def length = 14; def over_BoughtTD = 70; def over_SoldTD = 30; def price = close; def averageType = AverageType.WILDERS; def showBreakoutSignals = no; def NetChgAvg = MovingAverage(averageType, price - price[1], length); def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSITD = 50 * (ChgRatio + 1); def OverSold = over_sold; def OverBought = over_bought; ## TD RSI # DI Indicator def DI_length = 5; def "DI+" = DIPlus(DI_length); def "DI-" = DIMinus(DI_length); def "10" = 10; def "5" = 5; def "60" = 60; def "80" = 80; def "2" = 2; ##VOL BAND def priceVOL = hlc3; def averageLength = 8; def volatilityLength = 13; def deviationFactor = 3.55; def lowBandAdjust = 0.9; def typical = if priceVOL >= priceVOL[1] then priceVOL - low[1] else priceVOL[1] - low; def deviation = deviationFactor * Average(typical, volatilityLength); def devHigh = ExpAverage(deviation, averageLength); def devLow = lowBandAdjust * devHigh; def medianAvg = ExpAverage(priceVOL, averageLength); def MidLine = Average(medianAvg, averageLength); def UpperBand = ExpAverage(medianAvg, averageLength) + devHigh; def LowerBand = ExpAverage(medianAvg, averageLength) - devLow; ##VOL BAND END ##DEF BOTTOM SIGNALS def GWRSIBOTTOM3 = if ("%K" <= 1 && "%D" <= 1) then 3 else 0; def GWRSIBOTTOM2 = if GWRSIBOTTOM3 == 3 then 0 else if ("%K" <= 5 && "%D" <= 5) then 2 else 0; def GWRSIBOTTOM1 = if GWRSIBOTTOM2 == 2 then 0 else if GWRSIBOTTOM3 == 3 then 0 else if ("%K" <= 0) then 1 else if ("%K" <= 10 && "%D" <= 10) then 1 else if ("%D" <= 0) then 1 else 0; def TDRSI3 = if (RSITD <= 27) then 3 else 0; def TDRSI2 = if TDRSI3 == 3 then 0 else if (RSITD <= 30) then 2 else 0; def TDRSI1 = if TDRSI2 == 2 then 0 else if TDRSI3 == 3 then 0 else if (RSITD <= 33) then 1 else 0; def "DI-3" = if ("DI-" <= 2 ) then 3 else 0; def "DI-1" = if ("DI-" >= 75 ) then 2 else 0; def "DI-2" = if "DI-3" == 3 then 0 else if ("DI-" <= 8 ) then 1 else 0; def VolBandBottom3 = if (open <= LowerBand && close <= LowerBand) then 3 else 0; def VolBandBottom2 = if VolBandBottom3 == 3 then 0 else if (close <= LowerBand) then 2 else 0; def VolBandBottom1 = if VolBandBottom2 == 2 then 0 else if VolBandBottom3 == 3 then 0 else if (low <= LowerBand) then 1 else 0; ##DEF TOP SIGNALS def GWRSITOP3 = if ("%K" >= 99 && "%D" >= 99) then 3 else 0; def GWRSITOP2 = if GWRSITOP3 == 3 then 0 else if ("%K" >= 95 && "%D" >= 95) then 2 else 0; def GWRSITOP1 = if GWRSITOP2 == 2 then 0 else if GWRSITOP3 == 3 then 0 else if ("%K" >= 100) then 1 else if ("%K" >= 90 && "%D" >= 90) then 1 else if ("%D" >= 100) then 1 else 0; def TDRSIT3 = if (RSITD >= 73) then 3 else 0; def TDRSIT2 = if TDRSIT3 == 3 then 0 else if (RSITD >= 70) then 2 else 0; def TDRSIT1 = if TDRSIT2 == 2 then 0 else if TDRSIT3 == 3 then 0 else if (RSITD >= 67) then 1 else 0; def "DI+3" = if ("DI+" <= 2 ) then 3 else 0; def "DI+1" = if ("DI+" >= 75 ) then 2 else 0; def "DI+2" = if "DI+3" == 3 then 0 else if ("DI+" <= 8 ) then 1 else 0; def VolBandTOP3 = if (open >= UpperBand && close >= UpperBand) then 3 else 0; def VolBandTOP2 = if VolBandTOP3 == 3 then 0 else if (close >= UpperBand) then 2 else 0; def VolBandTOP1 = if VolBandTOP2 == 2 then 0 else if VolBandTOP3 == 3 then 0 else if (high >= UpperBand) then 1 else 0; ###TRIN CHOP SIGNALS def TRINSP = if (trin_cSP <= .70 or trin_cSP >= 1.40) then 0 else 1; def TRINNAS = if (trin_cNAS <= .70 or trin_cNAS >= 1.40) then 0 else 1; def TRINNY = if (trin_c <= .70 or trin_c >= 1.40) then 0 else 1; def TRINSignal = if (TRINSP == 1 && TRINNAS == 1 && TRINNY == 1) then 3 else if (TRINSP == 1 or TRINNAS == 1 or TRINNY == 1) then 1 else 0; def TOPCount = GWRSITOP1 + GWRSITOP2 + GWRSITOP3 + TDRSIT1 + TDRSIT2 + TDRSIT3 + "DI+1" + "DI+2" + "DI+3" + VolBandTOP1 + VolBandTOP2 + VolBandTOP3; def BottomCount = GWRSIBOTTOM1 + GWRSIBOTTOM2 + GWRSIBOTTOM3 + TDRSI1 + TDRSI2 + TDRSI3 + "DI-1" + "DI-2" + "DI-3" + VolBandBottom1 + VolBandBottom2 + VolBandBottom3; def toppercent = TRINSignal + TOPCount; def bottompercent = TRINSignal + BottomCount; def topsignal = if toppercent >4 then toppercent/13*100 else 0 ; def bottomsignal = if bottompercent >4 then bottompercent/13*100 else 0 ; def topsignalfinl =round(topsignal,0) ; def bottomsignalfinl =round(bottomsignal,0) ; ###### SIGNAL AddChartBubble(bottomsignalfinl,low, bottomsignalfinl+"%", Color.green,No); AddChartBubble("time condition" = topsignalfinl, "price location" = high, text = topsignalfinl + "%", color = Color.RED);
Re: Fun with ThinkScript April 09, 2018 04:44PM |
Registered: 6 years ago Posts: 33 |
Re: Fun with ThinkScript April 12, 2018 10:23AM |
Registered: 9 years ago Posts: 12 |
Re: Fun with ThinkScript April 17, 2018 08:16AM |
Registered: 7 years ago Posts: 6 |
Re: Fun with ThinkScript April 20, 2018 04:46PM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 24, 2018 02:28AM |
Registered: 7 years ago Posts: 6 |
Re: Fun with ThinkScript April 24, 2018 09:09AM |
Registered: 6 years ago Posts: 33 |
under construction mtf indicator April 24, 2018 09:10AM |
Registered: 6 years ago Posts: 33 |
Re: Fun with ThinkScript April 25, 2018 07:15PM |
Registered: 6 years ago Posts: 32 |
Re: Fun with ThinkScript April 25, 2018 08:31PM |
Registered: 9 years ago Posts: 67 |
def n = 2; def fastLength = 12; def over_bought = 70; def price = close; def over_sold =30; def averageType = AverageType.WILDERS; def bar = barNumber(); def Diff = rsi(fastLength, over_bought, over_sold,close, averageType); def OverSold = over_Sold; def OverBought = over_Bought; def UpSignal = if diff crosses above OverSold then OverSold else Double.NaN; def DownSignal = if diff crosses below OverBought then OverBought else Double.NaN; def CurrMACDh = if Diff > 70 then fold i = 1 to n + 1 with p = 1 while p do Diff > getValue(Diff, -i) else 0; def CurrMACDPivotH = if (bar > n and Diff == highest(Diff, n) and CurrMACDh) then Diff else double.NaN; def CurrMACDl = if Diff < 30 then fold j = 1 to n + 1 with q = 1 while q do Diff < getValue(Diff, -j) else 0; def CurrMACDPivotL = if (bar > n and Diff == lowest(Diff, n) and CurrMACDl) then Diff else double.NaN; def CurrPHBar = if !isNaN(CurrMACDPivotH) then bar else CurrPHBar[1]; def CurrPLBar = if !isNaN(CurrMACDPivotL) then bar else CurrPLBar[1]; def PHpoint = if !isNaN(CurrMACDPivotH) then CurrMACDPivotH else PHpoint[1]; def priorPHBar = if PHpoint != PHpoint[1] then CurrPHBar[1] else priorPHBar[1]; def PLpoint = if !isNaN(CurrMACDPivotL) then CurrMACDPivotL else PLpoint[1]; def priorPLBar = if PLpoint != PLpoint[1] then CurrPLBar[1] else priorPLBar[1]; def HighPivots = bar >= highestAll(priorPHBar); def LowPivots = bar >= highestAll(priorPLBar); def pivotHigh = if HighPivots then CurrMACDPivotH else double.NaN; def pivotLow = if LowPivots then CurrMACDPivotL else double.NaN; plot PivotDot = if !isNaN(pivotHigh) then pivotHigh else if !isNaN(pivotLow) then pivotLow else double.NaN;
Re: Fun with ThinkScript April 25, 2018 09:54PM |
Registered: 8 years ago Posts: 5 |
Re: Fun with ThinkScript April 25, 2018 10:07PM |
Registered: 6 years ago Posts: 32 |
Re: Fun with ThinkScript April 25, 2018 10:24PM |
Registered: 8 years ago Posts: 5 |
Re: Fun with ThinkScript April 26, 2018 07:39AM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 26, 2018 09:35AM |
Registered: 7 years ago Posts: 6 |
Leavitt convolution April 26, 2018 02:39PM |
Registered: 6 years ago Posts: 2 |
def price = Close; input length = 9; def intLength = Floor(Sqrt(length)); plot lc = inertia(inertia(price, length), intLength); lc.AssignValueColor(if lc > lc[1] then Color.GREEN else Color.RED);The function, inertia, needs to be replaced buy a new function called LeavittProjection. It uses the same a & b as inertia. while inertia plots ax + b my function should plot a(x-1)+b. I presume this is one bar ahead of the close.
script LeavittProjection{ input y = close; input n = 20; rec x = x[1] + 1; def a = (n * sum(x * y, n) - sum(x, n) * sum(y, n) ) / ( n *sum(Sqr(x), n) - Sqr(sum(x, n))); def b = (sum(Sqr(x), n) * sum(y, n) - sum(x, n) * sum(x *y, n) ) / ( n * sum(Sqr(x), n) - Sqr(sum(x, n))); plot LeavittProjection= a * (x - 1) + b;
Re: Fun with ThinkScript April 26, 2018 08:16PM |
Registered: 6 years ago Posts: 32 |
Re: Fun with ThinkScript April 26, 2018 09:12PM |
Registered: 5 years ago Posts: 2 |
Re: Fun with ThinkScript April 26, 2018 09:24PM |
Registered: 5 years ago Posts: 2 |
Quote
robert
Based on user input, this script will mark the high and low from the previous x number of days. it will work for any charting time frame from 1 minute up to and including a daily chart.
Re: Leavitt convolution April 27, 2018 05:57AM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 28, 2018 07:26AM |
Registered: 7 years ago Posts: 126 |
Quote
mikew
rigel - Thanks for trying but unfortunately the
scan is still starting the hourly candle at 9:00am
instead of 9:30am.
I think I'm going to have to use a 30 minute time
frame and figure out how get it from there. I'll
be sure to post my findings if I find a solution.
Re: Fun with ThinkScript April 29, 2018 08:35AM |
Registered: 7 years ago Posts: 126 |
# Plot the high and low of X days ago # Don't know the author of original code to give proper credit # Basic code modified to produce similar results to Robert Payne's solution # by Rigel April 2018 # declare upper; input LastBubble = No; Input DaysAgo = 1;#hint DaysAgo: Excludes today def AdjDaysAgo = DaysAgo + 1;#Adjusted to match a true LastDate which includes today def day = GetDay(); def lastDay = GetLastDay(); def year = GetYear(); def lastYear = GetLastYear(); def yyyymmdd = GetYYYYMMDD(); def agg=aggregationPeriod.DAY; As the author of the request seems not interested the rest of the code has been deleted
Re: Leavitt convolution April 29, 2018 09:33AM |
Registered: 6 years ago Posts: 2 |
Re: Leavitt convolution April 29, 2018 10:02AM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript April 29, 2018 02:40PM |
Registered: 6 years ago Posts: 32 |