Re: count highs and lows March 19, 2019 08:13AM |
Registered: 5 years ago Posts: 2 |
Re: Study filter - hourly intraday - condition met for any of 7 candles March 19, 2019 10:43PM |
Registered: 5 years ago Posts: 2 |
Re: count highs and lows March 20, 2019 12:26PM |
Registered: 5 years ago Posts: 2 |
def dLo = xxLow; def dHi = xxHigh; def diff = xxHigh - xxLow; def avg = average(diff,1900); input xSp = " "; AddChartBubble(showBubbleschange and !IsNaN("ZZ$" ) and barNumber != 1, close+2.5, if isUp then avg+ "\n"+"this"+dHi+"\n"+xSp+"-"+diff + "\nlast "+dLo else avg+ "\n"+"last"+dLo+"\n"+xSp+"-"+diff + "\nthis "+dHi ,color.white,yes);6. But I can't figure out why diff is sometimes negative number, even when I take the abs.
Custom Watchlist column March 21, 2019 12:25PM |
Registered: 5 years ago Posts: 1 |
Tick Study Alert March 29, 2019 09:45AM |
Registered: 9 years ago Posts: 11 |
Re: Fun with ThinkScript March 31, 2019 02:35AM |
Registered: 9 years ago Posts: 67 |
script isABCD { input _mode=0; input abc=0; input bcd=0; input d=0; input c=0; def _abc = abc >= 0.382 and abc <= 0.886; def _bcd = bcd >= 1.13 and bcd <= 2.618; def ret =_abc and _bcd and (if _mode == 1 then d < c else d > c); } def u_abcd2 = isABCD(1,abc,bcd,d,c) and isABCD(1,abc,bcd,d,c)[1]==0;I've tried a myriad of different approaches to solve the issue, but nothing has worked. I'm hoping a fellow scripter might be able to provide some insight into how a function (script) might be rewritten to work within a scan...
Re: Fun with ThinkScript March 31, 2019 07:18AM |
Registered: 5 years ago Posts: 1 |
script func { # simple fuction input x = 0; plot f = x - 2.035; } script Bisec { input a = 1.0001; input b = 2.31; def e = 0.00001; def mn = a; def mx = b; plot ret = fold i = 0 to 100 with mid=(a +b) / 2 while mx - mn > e do { if func(mn) * func(mid) < 0 then mx == mid else mn == mid; mid=(mn + mx) / 2; } } def res = Bisec().ret; AddLabel(yes, "Res = " + res);
// Bisection Method - Solves: x^2 - 3 = 0 public class Bisection01 { public static void main(String[] args) { final double epsilon = 0.00001; double a, b, m, y_m, y_a; a = 0; b = 4; while ( (b-a) > epsilon ) { m = (a+b)/2; // Mid point y_m = m*m - 3.0; // y_m = f(m) y_a = a*a - 3.0; // y_a = f(a) if ( (y_m > 0 && y_a < 0) || (y_m < 0 && y_a > 0) ) { // f(a) and f(m) have different signs: move b b = m; } else { // f(a) and f(m) have same signs: move a a = m; } System.out.println("New interval: [" + a + " .. " + b + "]" // Print progress } System.out.println("Approximate solution = " + (a+b)/2 ); } }
Re: Fun with ThinkScript April 01, 2019 11:52PM |
Registered: 9 years ago Posts: 67 |
script isRegularFractal { input mode = 0; plot ret = if mode == 1 then high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] else if mode == -1 then low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] else 0; } script isBWFractal { input mode = 0; plot ret = if mode == 1 then high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] else if mode == -1 then low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] else 0; } input filterBW = No; input ShowTimeFractals1 = No; def bn = BarNumber(); def h2 = high[2]; def l2 = low[2]; def filteredtopf = if filterBW then isRegularFractal(1) else isBWFractal(1); def filteredbotf = if filterBW then isRegularFractal(-1) else isBWFractal(-1); def b1_0 = if bn == 0 then -1 else if filteredtopf == 0 then 0 else if b1_0[1] > -1 then b1_0[1] + 1 else -1; def b1_1 = b1_0 + GetValue(b1_0, b1_0 + 1, 0) + 1; def b1_2 = b1_1 + GetValue(b1_0, b1_1 + 1, 0) + 1; def b2_0 = if bn == 0 then -1 else if filteredbotf == 0 then 0 else if b2_0[1] > -1 then b2_0[1] + 1 else -1; def b2_1 = b2_0 + GetValue(b2_0, b2_0 + 1, 0) + 1; def b2_2 = b2_1 + GetValue(b2_0, b1_1 + 1, 0) + 1; def higherhigh = if filteredtopf == 0 or b1_2 == b1_1 then 0 else GetValue(high[2], b1_1, 0) < GetValue(high[2], b1_0, 0) and GetValue(high[2], b1_2, 0) < GetValue(high[2], b1_0, 0); def lowerhigh = if filteredtopf == 0 or b1_2 == b1_1 then 0 else GetValue(high[2], b1_1, 0) > GetValue(high[2], b1_0, 0) and GetValue(high[2], b1_2, 0) > GetValue(high[2], b1_0, 0); def higherlow = if filteredbotf == 0 or b2_2 == b2_1 then 0 else GetValue(low[2], b2_1, 0) < GetValue(low[2], b2_0, 0) and GetValue(low[2], b2_2, 0) < GetValue(low[2], b2_0, 0); def lowerlow = if filteredbotf == 0 or b2_2 == b2_1 then 0 else GetValue(low[2], b2_1, 0) > GetValue(low[2], b2_0, 0) and GetValue(low[2], b2_2, 0) > GetValue(low[2], b2_0, 0); def hh = if bn == 0 then -1 else if higherhigh == 1 then 0 else if hh[1] > -1 then hh[1] + 1 else -1; def ll = if bn == 0 then -1 else if lowerlow == 1 then 0 else if ll[1] > -1 then ll[1] + 1 else -1; def higherhhigh = if higherhigh == 0 or hh == -1 then 0 else GetValue(high[2], hh, 0) >= high; def lowerllow = if lowerlow == 0 or ll == -1 then 0 else GetValue(low[2], ll, 0) <= low; def istop = if ShowTimeFractals1 then (if higherhhigh then 1 else 0) else (if filteredtopf then 1 else 0); def isbot = if ShowTimeFractals1 then (if lowerllow then 1 else 0) else (if filteredbotf then 1 else 0); def topcount0 = if istop then bn else topcount0[1]; def botcount0 = if isbot then bn else botcount0[1]; def topcount = bn - topcount0; def botcount = bn - botcount0; def zigzag = if istop and topcount[1] > botcount[1] then h2 else if isbot and topcount[1] < botcount[1] then l2 else Double.NaN; def z_0 = if bn == 0 then -1 else if IsNaN(zigzag) == 0 then 0 else if z_0[1] > -1 then z_0[1] + 1 else -1; def z_1 = z_0 + GetValue(z_0, z_0 + 1, 0) + 1; def z_2 = z_1 + GetValue(z_0, z_1 + 1, 0) + 1; def z_3 = z_2 + GetValue(z_0, z_2 + 1, 0) + 1; def z_4 = z_3 + GetValue(z_0, z_3 + 1, 0) + 1; def z_5 = z_4 + GetValue(z_0, z_4 + 1, 0) + 1; def x = GetValue(zigzag, z_4, 0); def a = GetValue(zigzag, z_3, 0); def b = GetValue(zigzag, z_2, 0); def c = GetValue(zigzag, z_1, 0); def d = GetValue(zigzag, z_0, 0); #def de = if d and istop then high else de[1]; #def ce = if c and isbot then low else ce[1]; #def be = if b and istop then high else be[1]; #def ae = if a and isbot then low else ae[1]; def du = if d and isbot then low else du[1]; def cu = if c and istop then high else cu[1]; def bu = if b and isbot then low else bu[1]; def au = if a and istop then high else au[1]; #def abc_be; #def bcd_be; def abc_bu; def bcd_bu; if topcount0 > botcount0 { abc_bu = round((AbsValue(bu - cu) / AbsValue(bu- au)),2); bcd_bu = round((AbsValue(du - cu) / AbsValue(bu - cu)),2); # abc_be = round((AbsValue(ae- be) / AbsValue(ae - be)),2); # bcd_be = round((AbsValue(be - de) / AbsValue(ae - be)),2); }else { abc_bu = round((AbsValue(bu - cu) / AbsValue(bu- au)),2); bcd_bu = round((AbsValue(du - cu) / AbsValue(bu - cu)),2); # abc_be = round((AbsValue(ae- be) / AbsValue(ae - be)),2); # bcd_be = round((AbsValue(be - de) / AbsValue(ae - be)),2); } def bull = between(bcd_bu,1.13,2.618)&& between(abc_bu,.382,.886); #def bear = between(bcd_be,1.13,2.618)&& between(abc_be,.382,.886); plot scan = bull;
Re: Fun with ThinkScript April 04, 2019 12:12AM |
Registered: 5 years ago Posts: 1 |
MTF Simple Moving Average April 05, 2019 07:10AM |
Registered: 5 years ago Posts: 1 |
Re: MTF Simple Moving Average April 07, 2019 11:22AM |
Registered: 7 years ago Posts: 126 |
-------------------------------------------------------Quote
Superspot
Hi all, I am in need of a thinkscript, I want to
plot the 4Hr. 5SMA on to a 5Min. Chart. Any help
will be appreciated, thanks
Re: Fun with ThinkScript April 12, 2019 07:32PM |
Registered: 9 years ago Posts: 14 |
Re: Fun with ThinkScript April 14, 2019 11:15AM |
Registered: 5 years ago Posts: 2 |
Re: Fun with ThinkScript April 14, 2019 11:16AM |
Registered: 5 years ago Posts: 2 |
Re: chop indicator April 20, 2019 10:01AM |
Registered: 5 years ago Posts: 2 |
Equivolume Charts & Dynamic Volume April 28, 2019 10:21AM |
Registered: 5 years ago Posts: 2 |
Re: Equivolume Charts & Dynamic Volume May 04, 2019 10:32AM |
Registered: 7 years ago Posts: 126 |
#-------- Alerts def conditionBull = Crosses(DPO, UpperBand, CrossingDirection.Above) ; def conditionBear = Crosses(DPO, LowerBand, CrossingDirection.Below) ; Alert(conditionBull, "Bullish!", Alert.BAR,sound.ring) ; Alert(conditionBear, "Bearish!", Alert.BAR,sound.ring) ;
Re: Equivolume Charts & Dynamic Volume May 06, 2019 10:38PM |
Registered: 9 years ago Posts: 67 |
Cumulative indicator May 19, 2019 08:28AM |
Registered: 4 years ago Posts: 2 |
Re: Cumulative indicator May 20, 2019 04:00PM |
Registered: 7 years ago Posts: 126 |
Re: Cumulative indicator May 20, 2019 05:39PM |
Registered: 4 years ago Posts: 2 |
Re: Fun with ThinkScript May 22, 2019 08:10PM |
Registered: 5 years ago Posts: 9 |
Re: Fun with ThinkScript June 11, 2019 10:08AM |
Registered: 8 years ago Posts: 45 |
Triangle Breakout / Breakdown June 13, 2019 08:48PM |
Registered: 5 years ago Posts: 14 |
Re: Fun with ThinkScript June 14, 2019 12:01PM |
Registered: 4 years ago Posts: 1 |
VOLUME
Re: Fun with ThinkScript June 15, 2019 11:50AM |
Registered: 4 years ago Posts: 3 |
TOS script July 03, 2019 11:28PM |
Registered: 4 years ago Posts: 1 |
Re: TOS script July 06, 2019 04:34PM |
Registered: 5 years ago Posts: 5 |
# ___________________________________________________________ # ________________ DAY/ HI-LOW / VOLUME ____________________ # ___________________________________________________________ # input show_label = yes; input show_bubble = no; def period_Type = AggregationPeriod.DAY; def begin = close(period = period_Type)[1]; def end = close(period = period_Type); def NetChg = end - begin; def PctChg = (end / begin) - 1; def DayVolume = volume(period = "DAY" #AddLabel(show_label, "Open: " + Open + " High: " + High + " Low: " + Low + " Last: " + close + " " + " Volume: " + DayVolume + " " , if NetChg > 0 then CreateColor( 165, 105, 189 ) else if NetChg < 0 then CREATEColor( 46, 204, 113 ) else Color.LIGHT_GRAY); AddLabel(show_label, "Open: " + Open + " High: " + High + " Low: " + Low + " Volume: " + DayVolume + " " , if NetChg > 0 then CreateColor( 44, 62, 80) else if NetChg < 0 then CREATEColor( 46, 204, 113 ) else Color.LIGHT_GRAY); def bar = if IsNaN(close) then if yes then bar[1] else Double.NaN else BarNumber(); def ThisBar = HighestAll(bar); def barCount = if bar == ThisBar then close else Double.NaN;
Re: Fun with ThinkScript July 09, 2019 08:13PM |
Registered: 4 years ago Posts: 1 |