Re: Fun with ThinkScript July 24, 2019 07:08PM |
Registered: 7 years ago Posts: 6 |
input opentime = 0930; input ORend = 1000; def na = Double.NaN; # # Check if the opening range time is now # def ORActive = if GetLastDay() == GetDay() and SecondsFromTime(opentime) >= 0 and SecondsFromTime(ORend) < 0 then 1 else 0; # # Track the OR high and low # def ORHigh = if ORActive then high else na; def ORLow = if ORActive then low else na; # # Plot the OR high and low # plot ORAH = if GetLastDay() != GetDay() or !ORActive then na else HighestAll(ORHigh); plot ORAL = if GetLastDay() != GetDay() or !ORActive then na else LowestAll(ORLow); plot ORH = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else HighestAll(ORHigh); plot ORL = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else LowestAll(ORLow); # # Formatting # ORAH.SetStyle(Curve.SHORT_DASH); ORAL.SetStyle(Curve.SHORT_DASH); ORAH.SetDefaultColor(Color.GREEN); ORAL.SetDefaultColor(Color.RED); ORH.SetStyle(Curve.SHORT_DASH); ORL.SetStyle(Curve.SHORT_DASH); ORH.SetDefaultColor(Color.GREEN); ORL.SetDefaultColor(Color.RED); # # Add Cloud creates the shading # AddCloud(ORH, ORL); AddCloud(ORAL, ORAH); # # Alerts: # def alerttrigger = if (high >= ORH and low <= ORH) or (high >= ORL and low <= ORL) then 1 else 0; #replace the 1 with your definition # BLOCK CODE BELOW input alerttext = "OR Breakout!"; input UseAlerts = {false, default true}; input AlertType = {default "BAR", "ONCE", "TICK"}; def at = AlertType; input AlertSound = {"Bell", "Chimes", default "Ding", "NoSound", "Ring"}; Alert(alerttrigger and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);
Re: Fun with ThinkScript July 25, 2019 12:44AM |
Registered: 4 years ago Posts: 7 |
Re: Fun with ThinkScript July 27, 2019 07:12PM |
Registered: 4 years ago Posts: 7 |
Re: Fun with ThinkScript July 28, 2019 06:47AM |
Registered: 9 years ago Posts: 38 |
Symbol Crosses Moving Average Alert July 28, 2019 12:29PM |
Registered: 5 years ago Posts: 5 |
#Hint: The MovingAverage Scan allows you to filter out securities that have a Moving Average that is any given percent above or below then securities current price. #Wizard text: The #Wizard input: price #Wizard text: is at least #Wizard input: percentdiff #Wizard text:% #Wizard input: choice #Wizard text: the #Wizard input: length #Wizard text: period #Wizard input: AverageType #Wizard text: Moving Average input price = close; input length = 4; input choice = {default "Above"}; input AverageType = averageType.EXPONENTIAL; input percentdiff = 1; def avg = movingAverage(averageType,price,length); plot scan; scan = price >= avg * (1 + percentdiff / 100 ) within 2 bars;
Fibonacci July 27, 2019 09:51PM |
Registered: 4 years ago Posts: 3 |
Elliot wave July 27, 2019 09:50PM |
Registered: 4 years ago Posts: 3 |
Elliot Wave July 26, 2019 11:37PM |
Registered: 4 years ago Posts: 3 |
Re: Fibonacci July 30, 2019 11:43AM |
Registered: 5 years ago Posts: 5 |
#hint: <b>Fibonacci Retracements</b>\nFibonacci retracements use horizontal lines to indicate areas of support or resistance at the key Fibonacci levels before it continues in the original direction. These levels are created by drawing a trendline between two extreme points and then dividing the vertical distance by the key Fibonacci ratios of: 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%. #hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b> #hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b> #hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b> #hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.\n <b>(Default is 0%)</b> #hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.\n <b>(Default is 23.6%)</b> #hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.\n <b>(Default is 38.2%)</b> #hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.\n <b>(Default is 50%)</b> #hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.\n <b>(Default is 61.8%)</b> #hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.\n <b>(Default is 78.6%)</b> #hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.\n <b>(Default is 100%)</b> #wizard input: Price #wizard text: Inputs: Price: #wizard input: onExpansion #wizard text: onExpansion: #wizard input: Extend_to_left #wizard text: Extend_to_left: #wizard input: Coefficient0 #wizard text: Coefficient0: #wizard input: Coefficient_1 #wizard text: Coefficient_1: #wizard input: Coefficient_2 #wizard text: Coefficient_2: #wizard input: Coefficient_3 #wizard text: Coefficient_3: #wizard input: Coefficient_4 #wizard text: Coefficient_4: #wizard input: Coefficient_5 #wizard text: Coefficient_5: #wizard input: Coefficient_6 #wizard text: Coefficient_6: #SOURCE [usethinkscript.com] # COLORS and line style revised to match small dog auto fib # USE this script with small dog autofib input price = close; input high = high; input low = low; input onExpansion = Yes; input Extend_to_left = no; input Coefficient0 = 0.000; input coefficient_1 = .236; input Coefficient_2 = .382; input Coefficient_3 = .500; input Coefficient_4 = .618; Input Coefficient_5 = .786; input Coefficient_6 = 1.000; def a = HighestAll(high); def b = LowestAll(low); def barnumber = barNumber(); def c = if high == a then barnumber else double.nan; def d = if low == b then barnumber else double.nan; rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c); def highnumberall = HighestAll(highnumber); rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d); def lownumberall = LowestAll(lownumber); def upward = highnumberall > lownumberall; def downward = highnumberall < lownumberall; def x = AbsValue(lownumberall - highnumberall ); def slope = (a - b) / x; def slopelow = (b - a) / x; def day = getDay(); def month = getMonth(); def year = getYear(); def lastDay = getLastDay(); def lastmonth = getLastMonth(); def lastyear = getLastYear(); def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0); def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan); def line = b + (slope * (barnumber - lownumber)); def linelow = a + (slopelow * (barnumber - highnumber)); def currentlinelow = if barnumber <= lownumberall then linelow else double.nan; def currentline = if barnumber <= highnumberall then line else double.nan; Plot FibFan = if downward then currentlinelow else if upward then currentline else double.nan; FibFan.SetStyle(Curve.SHORT_DASH); FibFan.AssignValueColor(color.red); fibfan.hidebubble(); def range = a - b; Plot Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan; Retracement0.assignvaluecolor(color.red); retracement0.hidebubble(); Retracement0.SetStyle(Curve.FIRM); #AddChartBubble((barnumber == istodaybarnumber +10), retracement0, concat( "$", round(retracement0, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement0, concat( (coefficient0 * 100), "%", color.red, yes); AddChartBubble((upward and barnumber == lownumberall), retracement0, concat( (coefficient0 * 100), "%", color.red, yes); ## Retracement 1 = 0.236 Plot Retracement1 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan; Retracement1.assignvaluecolor(createcolor(46, 204, 113)); retracement1.hidebubble(); Retracement1.SetStyle(Curve.MEDIUM_DASH); #AddChartBubble((barnumber == istodaybarnumber+10), retracement1, concat( "$", round(retracement1, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement1, concat( (coefficient_1 * 100), "%", (createcolor(46, 204, 113))); AddChartBubble((upward and barnumber == lownumberall), retracement1, concat( (coefficient_1 * 100), "%", (createcolor(46, 204, 113)), yes); ## Retracement 2 = 0.382 Plot Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan; Retracement2.assignvaluecolor((createcolor(0,0,255))); retracement2.hidebubble(); Retracement2.SetStyle(Curve.LONG_DASH); #AddChartBubble((barnumber == istodaybarnumber+10), retracement2, concat( "$", round(retracement2, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement2, concat( (coefficient_2 * 100), "%",(createcolor(0,0,255)), yes); AddChartBubble((upward and barnumber == lownumberall), retracement2, concat( (coefficient_2 * 100), "%", (createcolor(204, 204, 255)), yes); ## Retracement 3 = 0.50 Plot Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan; Retracement3.assignvaluecolor((createcolor(255, 238, 88))); retracement3.hidebubble(); Retracement3.SetStyle(Curve.LONG_DASH); Retracement3.setLineWeight(2); #AddChartBubble((barnumber == istodaybarnumber+10), retracement3, concat( "$", round(retracement3, 2)), color.red, yes); #AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%", (createcolor( 255, 238, 88)), yes); AddChartBubble((downward and barnumber == highnumberall), retracement3, concat( (coefficient_3 * 100), "%", (createcolor( 255, 238, 88)), yes); AddChartBubble((upward and barnumber == lownumberall), retracement3, concat( (coefficient_3 * 100), "%", (createcolor( 255, 238, 88)), yes); ##Coefficient_4 = .618 Plot Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan; Retracement4.assignvaluecolor((createcolor(0, 230, 255))); retracement4.hidebubble(); Retracement4.SetStyle(Curve.MEDIUM_DASH); #AddChartBubble((barnumber == istodaybarnumber+10), retracement4, concat( "$", round(retracement4, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement4, concat( (coefficient_4 * 100), "%", (createcolor(0, 230, 255)), yes); AddChartBubble((upward and barnumber == lownumberall), retracement4, concat( (coefficient_4 * 100), "%", (createcolor(0, 230, 255)), yes); ## Coefficient_5 = .786; Plot Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan; Retracement5.assignvaluecolor((createcolor(153, 0, 255))); retracement5.hidebubble(); Retracement5.SetStyle(Curve.LONG_DASH); #AddChartBubble((barnumber == istodaybarnumber+10), retracement5, concat( "$", round(retracement5, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement5, concat( (coefficient_5 * 100), "%", (createcolor(153, 0, 255)), yes); AddChartBubble((upward and barnumber == lownumberall), retracement5, concat( (coefficient_5 * 100), "%", (createcolor(153, 0, 255)), yes); Plot Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range * coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range * coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range * coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan; Retracement6.assignvaluecolor(color.red); retracement6.hidebubble(); Retracement6.SetStyle(Curve.FIRM); #AddChartBubble((barnumber == istodaybarnumber+10), retracement6, concat( "$", round(retracement6, 2)), color.red, yes); AddChartBubble((downward and barnumber == highnumberall), retracement6, concat( (coefficient_6 * 100), "%", color.red, yes); AddChartBubble((upward and barnumber == lownumberall), retracement6, concat( (coefficient_6 * 100), "%", color.red, yes); alert((price crosses below Retracement0) , "Price crosses below Retracement Line 0" alert((price crosses above Retracement0) , "Price crosses above Retracement Line 0" alert((price crosses below Retracement1) , "Price crosses below Retracement Line 1" alert((price crosses above Retracement1) , "Price crosses above Retracement Line 1" alert((price crosses below Retracement2) , "Price crosses below Retracement Line 2" alert((price crosses above Retracement2) , "Price crosses above Retracement Line 2" alert((price crosses below Retracement3) , "Price crosses below Retracement Line 3" alert((price crosses above Retracement3) , "Price crosses above Retracement Line 3" alert((price crosses below Retracement4) , "Price crosses below Retracement Line 4" alert((price crosses above Retracement4) , "Price crosses above Retracement Line 4" alert((price crosses below Retracement5) , "Price crosses below Retracement Line 5" alert((price crosses above Retracement5) , "Price crosses above Retracement Line 5" alert((price crosses below Retracement6) , "Price crosses below Retracement Line 6" alert((price crosses above Retracement6) , "Price crosses above Retracement Line 6"
Re: Fun with ThinkScript August 03, 2019 12:59PM |
Registered: 4 years ago Posts: 7 |
Re: Fun with ThinkScript August 04, 2019 04:51AM |
Registered: 7 years ago Posts: 126 |
Multi time frame (MTF) On-Balance Volume (OBV) August 04, 2019 04:59AM |
Registered: 7 years ago Posts: 126 |
The Schaff Trend Cycle August 04, 2019 05:16AM |
Registered: 7 years ago Posts: 126 |
# [www.prorealcode.com] #From Prorealcode to TOS by Rigel # [researchtrade.com] declare lower; #//input parameters input TCLen = 10; input MA1 = 23; input MA2 = 50; def Factor= 0.5; # //{Calculate a MACD Line} def XMAC = ExpAverage(Close,MA1) - ExpAverage(Close,MA2); # //{1st Stochastic: Calculate Stochastic of a MACD} def Value1 = Lowest(XMAC,TCLen); def Value2 = Highest(XMAC,TCLen) - Value1; # //{%Fast K of MACD} def Frac1= if Value2 > 0 then ((XMAC - Value1)/Value2) * 100 else Frac1[1]; # //{Smoothed Calculation for % Fast D of MACD} def PF = PF[1] + (Factor * (Frac1 - PF[1])); # //{2nd Stochastic: DCalculate Stochastic of smoothed Percent Fast D, 'PF', above} def Value3 = Lowest(PF,TCLen); def Value4 = Highest(PF,TCLen) - Value3; # //{% of Fast K of PF} def Frac2= if Value4 > 0 then ((PF - Value3)/Value4) * 100 else Frac2[1]; # //{Smoothed Calculation for %Fast D of PF} def PFF = PFF[1] + (Factor * (Frac2 - PFF[1])); plot SFTC=PFF; #plot horizontal lines plot OverSold = 25; plot OverBought = 75;
Re: Multi time frame (MTF) On-Balance Volume (OBV) August 04, 2019 12:43PM |
Registered: 4 years ago Posts: 7 |
Re: Fun with ThinkScript August 04, 2019 12:45PM |
Registered: 4 years ago Posts: 7 |
Re: Multi time frame (MTF) On-Balance Volume (OBV) August 06, 2019 12:36PM |
Registered: 7 years ago Posts: 126 |
Quote
1uni_verse
I just think it may be what's behind the indicator. I'm trying to replicate what's pictured and I think the workings behind it are just two OBV's but with different settings
Re: Fun with ThinkScript August 11, 2019 03:52PM |
Registered: 7 years ago Posts: 6 |
how to find alternating high and low values within X bars August 15, 2019 11:34AM |
Registered: 7 years ago Posts: 6 |
Re: how to find alternating high and low values within X bars August 15, 2019 02:50PM |
Registered: 7 years ago Posts: 126 |
Re: how to find alternating high and low values within X bars August 15, 2019 05:24PM |
Registered: 7 years ago Posts: 6 |
Re: how to find alternating high and low values within X bars August 16, 2019 11:20AM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript August 18, 2019 06:35PM |
Registered: 4 years ago Posts: 7 |
Re: how to find alternating high and low values within X bars August 18, 2019 10:09PM |
Registered: 7 years ago Posts: 6 |
Price Movement August 18, 2019 02:16PM |
Registered: 4 years ago Posts: 1 |
Re: Fun with ThinkScript August 20, 2019 07:39AM |
Registered: 4 years ago Posts: 1 |
Re: how to find alternating high and low values within X bars August 20, 2019 04:25PM |
Registered: 7 years ago Posts: 126 |
Re: Fun with ThinkScript August 21, 2019 07:37AM |
Registered: 8 years ago Posts: 45 |
Re: Fun with ThinkScript August 21, 2019 08:45PM |
Registered: 8 years ago Posts: 2 |
Re: Fun with ThinkScript August 22, 2019 10:28PM |
Registered: 4 years ago Posts: 2 |
help with my autofib direction August 22, 2019 10:27PM |
Registered: 4 years ago Posts: 2 |