Re: Fun with ThinkScript February 07, 2015 04:52PM |
Registered: 10 years ago Posts: 615 |
Quote
StrategyNode
do you have a example code which shows how to count thinks in thinkscript?
def GreenCandle = Open > Close;
def GreenCount = SUM(GreenCandle, 10);
Re: Fun with ThinkScript February 07, 2015 05:28PM |
Registered: 9 years ago Posts: 34 |
Re: Fun with ThinkScript February 07, 2015 08:52PM |
Registered: 9 years ago Posts: 34 |
def GreenCandle = Close>Open; def RedCandle = Close<Open; def GreenCount = SUM(GreenCandle, 78); def RedCount = SUM(RedCandle, 78); Plot SignalUP = GreenCount[1]>RedCount[1]; signalUP.AssignvalueColor(IF signalUP THEN COLOR.GREEN ELSE Color.Red); AssignbackgroundColor(IF signalUP THEN COLOR.dark_GREEN ELSE Color.Red);
Re: Fun with ThinkScript February 07, 2015 10:43PM |
Registered: 10 years ago Posts: 615 |
Quote
StrategyNode
Now I have another question... is there a way to add all the volume from a green candle seperatly from a red candle?
def UpVolume = if GreenCandle then Volume else double.nan; def GreenVolume = SUM(UpVolume, 78); def DownVolume = if RedCandle then Volume else double.nan; def RedVolume = SUM(DownVolume, 78);
Re: Fun with ThinkScript February 08, 2015 01:30PM |
Registered: 9 years ago Posts: 34 |
def GreenCandle = Close>Open; def RedCandle = Close<Open; def UpVolume = if GreenCandle then Volume else double.nan; def GreenVolume = SUM(UpVolume, 78); def DownVolume = if RedCandle then Volume else double.nan; def RedVolume = SUM(DownVolume, 78); Plot SignalUP = GreenVolume[0]>RedVolume[0]; signalUP.AssignvalueColor(IF signalUP THEN COLOR.GREEN ELSE Color.Red); AssignbackgroundColor(IF signalUP THEN COLOR.dark_GREEN ELSE Color.Red);
Re: Fun with ThinkScript February 08, 2015 02:17PM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript February 08, 2015 02:29PM |
Registered: 9 years ago Posts: 34 |
Re: Fun with ThinkScript February 09, 2015 08:18PM |
Registered: 9 years ago Posts: 7 |
Re: Fun with ThinkScript February 09, 2015 10:06PM |
Registered: 10 years ago Posts: 615 |
Quote
az
Hi,
I have a graph of AAPL and would like to add several labels with the following criteria:
1. Display current price of $DJI, the symbol and the Net Change in green or red
2. Display current price of SPX, the symbol and the Net Change in green or red
3. Display current price of COMP, the symbol and the Net Change in green or red
Can you help?
Much appreciated.
Re: Fun with ThinkScript February 09, 2015 11:07PM |
Registered: 9 years ago Posts: 7 |
Re: Fun with ThinkScript February 20, 2015 01:32PM |
Registered: 12 years ago Posts: 373 |
Re: Fun with ThinkScript February 20, 2015 03:08PM |
Registered: 10 years ago Posts: 143 |
Scan for hammer bars February 20, 2015 03:56PM |
Registered: 9 years ago Posts: 11 |
Re: Fun with ThinkScript February 20, 2015 04:02PM |
Registered: 12 years ago Posts: 373 |
Re: Fun with ThinkScript February 20, 2015 04:04PM |
Registered: 12 years ago Posts: 373 |
Re: Fun with ThinkScript February 20, 2015 05:17PM |
Registered: 10 years ago Posts: 615 |
Quote
stefonk
Hi,
I am trying to generate a scan that will pull up candlesticks with hammer or shooting stars.The tail should be 3 times longer than the body and also there can be small wicks too. Is there a way to do this with a study in thinkscript?
Thanks
steve
# Calculate the length of the candle's wicks def UpperWick = high - Max(open, close); def LowerWick = Min(open, close) - low; # Calculate the length of the candle's body def CandleBody = AbsValue(open - close); # Compare the wicks to the body to ensure that one wick is 3x longer than the body # also compare the other wick to ensure that it is a "small" wick def Hammer = (UpperWick / CandleBody >= 3) and (LowerWick / CandleBody <= 0.5); def Star = (LowerWick / CandleBody >= 3) and (UpperWick / CandleBody <= 0.5); # A scan should define one (and only one) plot for output. This plot will signal on # either a hammer or a star; plot data = Hammer or Star;
Re: Fun with ThinkScript February 20, 2015 06:17PM |
Registered: 9 years ago Posts: 11 |
ZigZag Scan February 20, 2015 07:09PM |
Registered: 9 years ago Posts: 11 |
Re: ZigZag Scan February 20, 2015 08:05PM |
Registered: 10 years ago Posts: 615 |
plot UpStep = (upStep1 or upStep1[-1] or upStep2 or upStep2[-1]) and zigZag == low;
plot UpStep = (upStep1 or upStep1[-1] or upStep2 or upStep2[-1]) and zigZag == low;
plot UpStep = (upStep1[1] or upStep1 or upStep2[1] or upStep2) and zigZag[1] == low;
Re: ZigZag Scan February 21, 2015 02:32PM |
Registered: 10 years ago Posts: 615 |
plot trendup = close > ExpAverage(close, 8); trendup.AssignValueColor(if trendup then Color.UPTICK else Color.DOWNTICK); AssignBackgroundColor(if trendup then Color.UPTICK else Color.DOWNTICK);
plot NetSignal = close > close(period = "day" )[1]; AssignBackgroundColor(if NetSignal then Color.UPTICK else Color.DOWNTICK); NetSignal.AssignValueColor(if NetSignal then Color.UPTICK else Color.DOWNTICK);
plot OpenSignal = close - open(period = "day" ); AssignBackgroundColor(if OpenSignal > 0 then Color.UPTICK else Color.DOWNTICK); OpenSignal.AssignValueColor(if OpenSignal > 0 then Color.UPTICK else Color.DOWNTICK);
def Higher = close > high(period = "day" )[1]; def Lower = close < low(period = "day" )[1]; plot data = 1; data.AssignValueColor(if Higher then Color.UPTICK else if Lower then Color.DOWNTICK else Color.GRAY); AssignBackgroundColor(if Higher then Color.UPTICK else if Lower then Color.DOWNTICK else Color.GRAY);
Re: Fun with ThinkScript February 21, 2015 04:49PM |
Registered: 9 years ago Posts: 67 |
Re: Fun with ThinkScript February 21, 2015 04:58PM |
Registered: 12 years ago Posts: 321 |
Re: Fun with ThinkScript February 21, 2015 04:58PM |
Registered: 11 years ago Posts: 106 |
Re: Fun with ThinkScript February 21, 2015 05:29PM |
Registered: 10 years ago Posts: 615 |
Quote
NMR
Is it possible for you to quickly modify the code so that all that displays is a "Color.Dark_Orange" if it is outside of the Band- all else it is just BLACK? I am asking for this because I feel that the most important thing to know is weather the candle is IN BAND or OUT of BAND- and that is it- no numbers- and no 'min days in band' I use this to quickly scan my WS and see if there is an "OOB" play on the W, D or 233 charts (I have these columns set up on my watch list) and I essentially play a "SLING SHOT" on these.
def length = 21; def sDev = StDev(data = close, length = length); def Avg = Average(close, length); def UpperBand = Avg + 2 * sDev; def LowerBand = Avg - 2 * sDev; plot OutBand = close > UpperBand or close < LowerBand; Outband.AssignValueColor(if OutBand then color.dark_orange else color.black); AssignBackgroundColor(if OutBand then color.dark_orange else color.black);
Re: Fun with ThinkScript February 21, 2015 05:50PM |
Registered: 10 years ago Posts: 615 |
Quote
netarchitech
I am running into a little difficulty trying to incorporate the Volume Box study into my charts. More specifically, when I add the study to a 5 min chart, the candles get compacted making the chart impossible to analyze...
Re: Fun with ThinkScript February 21, 2015 09:40PM |
Registered: 9 years ago Posts: 67 |
Re: Fun with ThinkScript February 21, 2015 10:55PM |
Registered: 9 years ago Posts: 67 |
Re: Fun with ThinkScript February 22, 2015 08:54AM |
Registered: 9 years ago Posts: 67 |
# Plot Vertical Lines for Three Trading Blocks AddVerticalLine(SecondsFromTime(0930) >= 0 and SecondsFromTime(0930) < 60, "09:30", Color.WHITE); AddVerticalLine(SecondsFromTime(1100) >= 0 and SecondsFromTime(1100) < 60, "11:00", Color.LIME); AddVerticalLine(SecondsFromTime(1400) >= 0 and SecondsFromTime(1400) < 60, "14:00", Color.PINK);
Re: ZigZag Scan February 22, 2015 11:14AM |
Registered: 9 years ago Posts: 11 |
Re: ZigZag Scan February 22, 2015 11:57AM |
Registered: 10 years ago Posts: 615 |
Quote
netarchitech
Being a fledgling, aspiring Thinkscript programmer, I have taken the liberty of slightly modifying your Volume Box code to incorporate vertical lines delineating the starting times of the Three Trading Blocks. ...I hope this modification is acceptable.