Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: Fun with ThinkScript
December 17, 2015 10:25AM
Tanman,

Worked great on LKND and AMZN today on 30 minute time frame.
Re: Fun with ThinkScript
December 18, 2015 11:26AM
Robert C,

In the last 20 days it gave 5 winning signals and 1 losing signal (holding overnight if no result same day) in LNKD on 30 minute chart. I used 1.5 X ATR as stop loss and target profit from open of the candle with the arrow. Using same 1.5 x ATR stop loss and target profit, it gave 5 winning signals and no losses in AMZN in last 20 days.

It would be interesting to do this study over 6 months to see what the result would be but TOS has 30 minute time frame chart only for 20 days. Cursory glance shows it winning almost 60-70% time over last 3 months in LNKD and AMZN on 1 hour chart.

I have modified the code slightly adding On Balance Volume as a signal parameter which gives more trades and seems to win at almost same rate. The only difference is that entry is at the close of the candle with arrow instead of at the open. It gave 8 winning trades and 3 losing trades in LNKD in last 20 days on 30 minute chart. Here it is:

input inputStochLong = 22;
input inputStochShort = 78;

# return %k for going long on stochastics
def StochLong = StochasticFull(80,20,10,10,High,Low,Close,3, "SMA" ).FastK;
def longOneFilter = StochLong < inputStochLong;
def shortOneFilter = StochLong > inputStochShort;

# volume parameters
def AvgVol = Average(volume,6);
def VolUP = volume > AvgVol and volume > volume[1]*0.75;

# long and short signal formula
def OBV = TotalSum(Sign(close - close[1]) * volume);
def OBVUP = OBV > OBV[1];
def OBVDN = OBV < OBV[1];
def LongSignal1 = VolUP[1] and OBVUP and longOneFilter[1] and StochLong[1] > StochLong[2];
def ShortSignal1 = VolUP[1] and OBVDN and shortOneFilter[1] and StochLong[1] < StochLong[2];
plot SignalBuy = if LongSignal1 then low else Double.nan;
plot SignalSell = if ShortSignal1 then high else Double.nan;

# show up arrow for buy signal and down arrow for sell signal
SignalBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SignalBuy.AssignValueColor(color.UPTICK);
SignalSell.SetpaintingStrategy(PaintingStrategy.ARROW_DOWN);
SignalSell.AssignValueColor(color.RED);

# show alert and make sound
alert(SignalBuy, " TIME TO GO LONG", alert.BAR, sound.Bell);
alert(SignalSell, " TIME TO GO SHORT", alert.BAR, sound.Bell);



Edited 3 time(s). Last edit at 12/18/2015 11:58AM by tanman.
Re: Fun with ThinkScript
December 18, 2015 12:48PM
Can Robert or someone else please add buy/sell signals to the following script to make it a strategy. I am new to thinkscript and can't quite get it to work when I add the signals (am getting multiple throughout the day). A million thanks to the kind soul who can help me with this.

I'd like the following added to the code below to make it a strategy:

Buy if current price crosses above opening_range_high, place stop at opening range low. Exit if stop is hit or on market_close_time
Sell if current price crosses below opening_range_low, place stop at opening range high. Exit if stop is hit or on market_close_time

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
input openingRangeMinutes = 30;
input Market_Open_Time = 0930;
input Market_Close_Time = 1430;

def day = getDay();
def pastOpen = if((secondsTillTime(Market_Open_Time) > 0), 0, 1);
def pastClose = if((secondsTillTime(Market_Close_Time) > 0), 0, 1);
def marketOpen = if(pastOpen and !pastClose, 1, 0);
def firstBar = if (day[1] != day, day - 1, 0);

def secondsUntilOpen = secondsTillTime(Market_Open_Time);
def regularHours = secondsTillTime(Market_Close_Time);

def secondsFromOpen = secondsFromTime(Market_Open_Time);
def pastOpeningRange = if(secondsFromOpen >= (openingRangeMinutes *
60) + 1, 1, 0);

REC displayedHigh = if(high > displayedHigh[1] and marketOpen, high,
if(marketOpen and !firstBar, displayedHigh[1], high));
REC displayedLow = if(low < displayedLow[1] and marketOpen, low,
if(marketOpen and !firstBar, displayedLow[1], low));

rec ORHigh = if(pastOpeningRange, ORHigh[1], displayedHigh);
rec ORLow = if(pastOpeningRange, ORLow[1], displayedLow);

plot Opening_Range_High = if(pastOpeningRange and marketOpen, ORHigh,
double.nan);
plot Opening_Range_Low = if(pastOpeningRange and marketOpen, ORLow,
double.nan);
Opening_Range_High.SetDefaultColor(color.green);
Opening_Range_High.SetLineWeight(2);
Opening_Range_High.SetStyle(curve.POINTS);
Opening_Range_Low.SetDefaultColor(color.red);
Opening_Range_Low.SetLineWeight(2);
Opening_Range_Low.SetStyle(curve.POINTS);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks a million again to anyone who can help here.
NMR
Re: Fun with ThinkScript
December 18, 2015 04:39PM
Hi folks:
A question on how to use the new code that has been posted here. I am referring to the code that starts with:

input inputStochLong = 22;
input inputStochShort = 78;

# return %k for going long on stochastics
def StochLong = StochasticFull(80,20,10,10,High,Low,Close,3, "SMA" ).FastK;
def longOneFilter = StochLong < inputStochLong;
def shortOneFilter = StochLong > inputStochShort;
. . .

My question is:
How do you use this?
What chart timeframes are you all using this on?
Are you looking for an arrow on 1 chart or 3 (are you all using 1, 3 or 6 charts., etc.)
Any info would be great.

Thank you
Re: Fun with ThinkScript
December 18, 2015 04:43PM
Tanman,

I am working on different time frames for several stocks ( NFLX, LNKD, AAPL, BIDU, TSLA, FB ) to come up with a high percentage of profitable trade using 30, 55, 94, 128 minute time frames. Some are really high percentages such as NFLX on 55 min. I haven't tried your new code, but I will this weekend.

Thanks for all your work,
Re: Fun with ThinkScript
December 18, 2015 06:39PM
Quote
Tanman
> It would be interesting to do this study over 6
> months to see what the result would be but TOS has
> 30 minute time frame chart only for 20 days.
> Cursory glance shows it winning almost 60-70% time
> over last 3 months in LNKD and AMZN on 1 hour
> chart.
Tanman, funny I never thought about how to get more data depth 'til I read your post. To get a specified sample depth, I think it would be statistically legitimate to use horizontal sampling (check multiple stocks, as you've done with two) instead of vertical sampling (one stock). Personally, I don't do a lot of depth on mine and I like what I already see from yours. Could do lots of pinheaded controls, like volume, price, EPS, etc., but I think just a given price range is enough.
And thanks for the algo gift spinning smiley sticking its tongue out
Re: Fun with ThinkScript
December 21, 2015 10:29AM
Tanman,

94 min. time frame worked great this morning. Fridays 94 min candle triggered on LNKD, BIDU, APPL. I bought calls friday, and banked this morning on your first code. Still haven't researched the 2nd code.

Thanks
Re: Fun with ThinkScript
December 21, 2015 01:30PM
Tanman,

Played the 55 min candle on APPL BCO at 2.86 , sold out at 3.25. I was using the old code, and since added new code to try it.
Re: Fun with ThinkScript
December 21, 2015 02:39PM
I've browsed through here before and I'm sorry if I missed this topic but I don't think it's been covered and I can't find good resources elsewhere. What I'm looking for is this:

A rolling VWAP on a higher time frame: basically a 'volume weighted moving average' that I can set to different periods, such as 2-day, 30-day, 1-year, etc.

An anchored VWAP I can set to a certain date on a higher time frame, e.g. a daily VWAP that begins at a certain date in the past.

An intraday VWAP anchored to the session open that I can customize to a shorter time frames, e.g. a 15-minute, 30-minute, 60-minute, etc., but that begins at the session open like the normal VWAP.

Any help or guidance for building these for Thinkorswim would be greatly appreciated!!!
Re: Fun with ThinkScript
December 22, 2015 07:41AM
I've looked but can't find...

Can ThinkScript send a text message alert from the code?

For the code:

Alert(Cond1,GetSymbol() + " Near Support1", Alert.BAR, Sound.Chimes);

If possbile, where would the SMS text alert be?

Thanks
Thinkorswim PricOsc On Chart
December 25, 2015 08:16PM
Can Anyone please help me create a script that will show the priceOsc number on the chart itself with user defined settings.
Re: Thinkorswim PricOsc On Chart
December 26, 2015 12:06AM
Quote
Kamadi
-------------------------------------------------------
> Can Anyone please help me create a script that
> will show the priceOsc number on the chart itself
> with user defined settings.
Kamadi, you just copy the code, put it in a New Study, then delete "declare lower;". The plot of priceOsc will probably be at the bottom of the price chart and the price bars at the top. So right-click on the priceOsc plot and choose "Use Left Axis" and you're done. Works fine- I just did it but TDA has a copyright posted on the code so I don't want to post it here.
P.S.- the priceOsc number will appear in the left margin.



Edited 1 time(s). Last edit at 12/26/2015 12:09AM by baffled1.
Re: Fun with ThinkScript
December 27, 2015 12:56AM
Thank you Baffled1 for the quick response. I really appreciate it. I was wondering if there is a script I can use to make the PriceOsc as a chart label instead of having it on the left margin. Also have price colored by strength of the PriceOsc. Ive tried scripting this myself with the add Label function with thinkscript but with no luck.

Also is there a script that can pinpoint high/low pivot levels. that will either draw a line or change pricebar color when the high is greater than previous high and greater than the next high?



Edited 1 time(s). Last edit at 12/27/2015 01:13AM by Kamadi.
Re: Fun with ThinkScript
December 27, 2015 05:33AM
Yeah, Kamadi, it's do-able. I've seen stuff like that around here somewhere but frankly some of it's above my present skill level. Sorry. eye popping smiley
Re: Fun with ThinkScript
December 27, 2015 06:36AM
I got the PriceOsc label to work after many failed attempts I feel dumb for not figuring out a simple code. But can anyone help me put the title as well as the value. I want the label to look like this on my chart: PriceOsc = 3.32 .. Right now I just have the value only

def priceOsc = reference PriceOsc("colorNormLength" =7,"fastLength" = 14, "slowLength" = 9, price = close, averageType =AverageType.expONENTIAL);

AddLabel(yes, priceOsc, if priceOsc >= 0 or priceOsc <= 0 then Color.RED else Color.BLUE);



Edited 1 time(s). Last edit at 12/27/2015 06:37AM by Kamadi.
Re: Fun with ThinkScript
December 27, 2015 04:56PM
def priceOsc = reference PriceOsc("colorNormLength" =7,"fastLength" = 14, "slowLength" = 9, price = close, averageType =AverageType.expONENTIAL);
AddLabel(yes, " PriceOsc =" , if priceOsc >= 0 or priceOsc <= 0 then Color.RED else Color.BLUE);
AddLabel(yes, priceOsc , if priceOsc >= 0 or priceOsc <= 0 then Color.RED else Color.BLUE);

Try This
I am not a coder
Re: Fun with ThinkScript
December 28, 2015 12:30PM
Hello Kamadi,

I have modified the code. It should print a blue label when PriceOsc >= 0 and red label when PriceOsc < 0 and will say PriceOsc = value of the variable rounded to 3 decimal places. Currently the way you have coded, it will always print a red label no matter what.

def MyPriceOsc = reference PriceOsc("colorNormLength" = 7, "fastLength" = 14, "slowLength" = 9, price = close, averageType = AverageType.EXPONENTIAL);

AddLabel(yes, "PriceOsc = " + Round(MyPriceOsc, 3), if MyPriceOsc < 0 then Color.LIGHT_RED else Color.BLUE);
Re: Fun with ThinkScript
December 28, 2015 12:41PM
RobertC and baffled1,

You are welcome and great trades Robert! Please be careful and always use stop loss and position size the trades.

I have made a code for breakout traders if anyone is interested. It identifies a long tailed candle on high volume with tail in direction of trend, to go long if price goes above tail in an uptrend or to go short if price goes below tail in a downtrend. It seems to be a high percentage strategy once the price has broken out of previous day range or 30 minutes open range.

Hope everyone had a great Christmas and wish everyone a Happy New Year!
Re: Fun with ThinkScript
December 28, 2015 04:11PM
Tanman

Thank very much!! Gladly appreciate this. It worked like a charm
Re: Fun with ThinkScript
December 29, 2015 08:01AM
Tanman,

I am interested because I am using 15 minutes open range strategy. Thanks
Re: Fun with ThinkScript
December 29, 2015 01:04PM
Keiko,

I am also a breakout trader and trade 30 minute opening range and also the previous day range along with intraday trend analysis.

First I will give you an example from today to show how this long tail candle breakout code would have worked.

In LVS on a 2 minute chart, it gave a short signal below low of long tailed candle at 11:12 EST at a price of 44.39 just below low of 44.4, when LVS was in an intraday downtrend. This short limit order could have been placed at 11:14 in advance. This limit order was executed at 11:36 EST, 24 minutes later. The price then "whooshed" down to 44.1. The ATR at 11:36 was .07 so 1.5 x ATR gave stop loss at 44.50 just above the entry bar. First profit target was hit at 44.28 to sell half position and stop loss moved to 44.39. The second profit target was hit at 3 x ATR at 44.17 to close full position.

The next short signal came at 11:58 at 44.09 and then again at 12:02 EST at 44.11 just below low of long tailed candles. Recommend to use the most recent signal at 12:02 which gave earlier entry. This short was executed at 12:04 with stop loss of 1.5 x ATR at 44.22 (just above high of entry candle or at 1.5 x ATR). First profit target of 44 was hit at 12:12 for close of half position and stop loss moved to 44.11 entry price. Full position closed at 44.09 when green bar closed above last bar high.

The next signal at 12:12 has not been hit and there was end of intraday down trend after that so signal was cancelled.

1000 shares risked $110 to make $165 in first trade and risked $110 to make $65 in second trade for total profit of $230 in total of 40 minutes.

I only use very liquid stocks with following parameters:

1. Price under $50
2. Average daily volume > 3,000,000
3. Daily ATR percent > 3%
4. Bid-ask spread 1-2 cents to minimize slippage.

Here is the code for the long tailed trend breakout strategy. It plots a blue point at the long tailed signal candle and also gives an audible and written alert whenever the point is plotted. You can change the color of the point, and periods of exponential moving averages used to determine trend in the code itself. I used the 8, 21, and 50 period EMA. This code should also work for breakout swing traders on higher time frames.

# define long tail bar
def TailDown = (min(open, close) - low) > (high - low)*0.49;
def TailUp = (high - max(open, close)) > (high - low)*0.49;

# define high volume
def AvgVol = Average(volume, 6);
def VolUP = volume > AvgVol and volume > volume[1]*0.7;

# define trend
def MA1 = ExpAverage(close, 8);
def MA2 = ExpAverage(close, 21);
def MA3 = ExpAverage(close, 50);
def EUP = MA1 > MA2 && MA1 > MA3 && MA2 > MA3 && MA2 > MA2[2];
def EDN = MA1 < MA2 && MA1 < MA3 && MA2 < MA3 && MA2 < MA2[2];

# plot point at long bar or short bar
plot SignalBuy = if TailUp and EUP and VolUP then low - 0.03 else Double.nan;
plot SignalSell = if TailDown and EDN and VolUP then high + 0.03 else Double.nan;
SignalBuy.SetPaintingStrategy(PaintingStrategy.POINTS);
SignalBuy.AssignValueColor(color.BLUE);
SignalBuy.SetLineWeight(3);
SignalSell.SetpaintingStrategy(PaintingStrategy.POINTS);
SignalSell.AssignValueColor(color.BLUE);
SignalSell.SetLineWeight(3);

# show alert and make sound
alert(SignalBuy[1], " Buy above high of candle in uptrend: " + high[1], alert.BAR, sound.Bell);
alert(SignalSell[1], " Sell below low of candle in downtrend: " + low[1], alert.BAR, sound.Bell);

Good luck smiling smiley
Re: Fun with ThinkScript
December 30, 2015 09:52PM
OK I really could use help creating a script to identify trend pullback bars that paints the price bar yellow when these conditions are meet.If anyone could help me with this I will appreciate it

low is greater than low from 1 bar ago and
low from 1 bars ago is less than low from 2 bars ago and
MovAvgExp (Length=6) is less than MovAvgExp( Length=18) and
MovAvgExp (Length=6) from 1 bar ago is less than MovAvgExp (Length=18) from 1 bars ago and
MovAvgExp (Length=6) from 2 bars ago is greater than MovAvgExp(Length=18) from 2 bars ago

Basically I would like uptrend colors to be blue, Down Trends to be red and the pullback bars to turn Yellow when all conditions are meet.
Re: Fun with ThinkScript
December 31, 2015 09:34AM
Kamadi,

I don't promise anything but I can try to help you with this code. How do you define uptrend and downtrend? Additionally, I am just curious what time frame chart you want to use this code on? I played around with those conditions and found it extremely difficult to get a signal satisfying all those conditions even in a valid pullback.

I am a breakout day trader and my best entry signal is a pullback or retracement to support after a breakout. I define my support as the resistance prior to breakout and I have written a code which alerts me as soon as the candles start approaching my support. I can also write a code in which the candles start approaching an exponential moving average on a pullback in a trend. I find that if I identify a pullback candle after pullback is complete and the next candle has already started moving up then it is too late for entry, so I try to identify a pullback in which candles have just started approaching the support and then I manually identify the exact bounce.

For example, today SUNE gapped down and then had a strong breakout above resistance at $5. Price then pulled back to $5 support and bounced up to give a quick 10 cents profit on a $5 stock. Even though this pullback was a good one, 6 EMA never went below 18 EMA on 1 minute chart!



Edited 2 time(s). Last edit at 12/31/2015 10:24AM by tanman.
Re: Fun with ThinkScript
December 31, 2015 10:57AM
Tanman,

I use ExpMovAverges to classify a up or down trend. using the 50,18,6 ema. if overall price is below 50ema and the 18ema is below the 50 I consider that a downtrend vice versa for longs. The time frame I use is the Daily chart. Ive noticed on a trending stock the best entry is finding pullback bars. I am interested in the code for candles approaching an Ema. Anyway you can help will be gladly appreciated
Re: Fun with ThinkScript
December 31, 2015 01:30PM
Kamadi,

Here it is. This code will do the following:

1. It will paint uptrend bars in blue and downtrend bars in red (as defined by you), and bars that are neither in uptrend nor downtrend in gray.
2. It will paint the pullback bar in yellow and will also plot a green up arrow below the yellow bar if bullish pullback and red down arrow above the yellow bar if bearish pullback.
3. It will give you audible and written alert when price approaches 6, 18, or 50 EMA and will also tell you if it is approaching from above or approaching from below.
4. It will print a green label with the value of 6, 18, or 50 EMA when price approaches those moving averages from above.
5. It will print a red label with the value of 6, 18, or 50 EMA when price approaches those moving averages from below.
6. It will give you audible and written alert when price crosses 6 EMA from above or below on high volume.
7. It will print a green label saying "Bull Cross" for bullish reversal crossing of 6 EMA on high volume from below and red label saying "Bear Cross" for bearish reversal crossing of 6 EMA on high volume from above.
8. It will print a green label saying "UP" when stock is in uptrend, red label saying "DN" when stock is in downtrend, and gray label saying "NO" when neither uptrend nor downtrend.
9. It will display the ATR of the current time frame in gray label.
10. It will display the ADX value of the current time frame in green label if it is > 20 or red label if it is <= 20. It will display ">" in front of value if ADX is going up or "<" in front of value if ADX is going down.

You can delete the code for anything you don't want or change what it says in alerts or labels or the colors by changing it in the code.

Hope this meets your needs.



# define moving averages and trend
def MA1 = ExpAverage(close, 6);
def MA2 = ExpAverage(close, 18);
def MA3 = ExpAverage(close, 50);
def UP = MA2 > MA3 and close > MA3;
def DN = MA2 < MA3 and close < MA3;
def Neutral = !UP and !DN;

# define high volume
def AvgVol = Average(volume, 50);
def VolUP = volume > AvgVol;

# define ATR
def ATR = WildersAverage(TrueRange(high, close, low), 14);

# define signals
def UPpullback = low > low[1] and low[1] < low[2] and MA1 < MA2 and MA1[1] < MA2[1] and MA1[2] > MA2[2];
def DNpullback = high < high[1] and high[1] > high[2] and MA1 > MA2 and MA1[1] > MA2[1] and MA1[2] < MA2[2];
def MA6bullapproach = min(open, close) < (MA1 + ATR*0.5) and close >= MA1 and close[1] > MA1 and close[2] > MA1;
def MA6bearapproach = max(open, close) > (MA1 - ATR*0.5) and close <= MA1 and close[1] < MA1 and close[2] < MA1;
def MA18bullapproach = min(open, close) < (MA2 + ATR*0.5) and close >= MA2 and close[1] > MA2 and close[2] > MA2;
def MA18bearapproach = max(open, close) > (MA2 - ATR*0.5) and close <= MA2 and close[1] < MA2 and close[2] < MA2;
def MA50bullapproach = min(open, close) < (MA3 + ATR*0.5) and close >= MA3 and close[1] > MA3 and close[2] > MA3;
def MA50bearapproach = max(open, close) > (MA3 - ATR*0.5) and close <= MA3 and close[1] < MA3 and close[2] < MA3;
def bullreversal = open < MA1 and close > MA1 and close[1] < MA1[1] and close[2] < MA1[2] and volume > AvgVol;
def bearreversal = open > MA1 and close < MA1 and close[1] > MA1[1] and close[2] > MA1[2] and volume > AvgVol;

# paint bars blue in uptrend, red in downtrend and yellow after pullback bounce
assignpricecolor(if UP then color.BLUE else if DN then color.RED else if UPpullback then color.YELLOW else if DNpullback then color.YELLOW else color.GRAY);

# show up arrow for buy signal and down arrow for sell signal
plot SignalBuy = if UPpullback then low else Double.NaN;
SignalBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SignalBuy.AssignValueColor(Color.UPTICK);
plot SignalSell = if DNpullback then high else Double.NaN;
SignalSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SignalSell.AssignValueColor(Color.RED);

# trigger alerts
Alert(UPpullback, GetSymbolPart() + " bounce after bullish pullback", Alert.BAR, Sound.Ring);
Alert(DNpullback, GetSymbolPart() + " bounce after bearish pullback", Alert.BAR, Sound.Ring);
Alert(MA6bullapproach, GetSymbolPart() + " approaching 6 EMA from above", Alert.BAR, Sound.Bell);
Alert(MA6bearapproach, GetSymbolPart() + " approaching 6 EMA from below", Alert.BAR, Sound.Bell);
Alert(MA18bullapproach, GetSymbolPart() + " approaching 18 EMA from above", Alert.BAR, Sound.Bell);
Alert(MA18bearapproach, GetSymbolPart() + " approaching 18 EMA from below", Alert.BAR, Sound.Bell);
Alert(MA50bullapproach, GetSymbolPart() + " approaching 50 EMA from above", Alert.BAR, Sound.Bell);
Alert(MA50bearapproach, GetSymbolPart() + " approaching 50 EMA from below", Alert.BAR, Sound.Bell);
Alert(bullreversal, GetSymbolPart() + " price crossed 6 EMA from below on high volume", Alert.BAR, Sound.Ring);
Alert(bearreversal, GetSymbolPart() + " price crossed 6 EMA from above on high volume", Alert.BAR, Sound.Ring);

# add labels
AddLabel(UP, "UP", Color.UPTICK);
AddLabel(DN, "DN", Color.DOWNTICK);
AddLabel(Neutral, "NO", Color.GRAY);
AddLabel(MA6bullapproach, "6 EMA: " + Round(MA1, 2), Color.UPTICK);
AddLabel(MA6bearapproach, "6 EMA: " + Round(MA1, 2), Color.DOWNTICK);
AddLabel(MA18bullapproach, "18 EMA: " + Round(MA2, 2), Color.UPTICK);
AddLabel(MA18bearapproach, "18 EMA: " + Round(MA2, 2), Color.DOWNTICK);
AddLabel(MA50bullapproach, "50 EMA: " + Round(MA3, 2), Color.UPTICK);
AddLabel(MA50bearapproach, "50 EMA: " + Round(MA3, 2), Color.DOWNTICK);
AddLabel(bullreversal, "Bull Cross ", Color.UPTICK);
AddLabel(bearreversal, "Bear Cross ", Color.DOWNTICK);
AddLabel(yes, "ATR = " + Round(ATR, 2), Color.GRAY);

# calculate current ADX and display in label
def h = high;
def l = low;
def c = close;

def hiDiff = h - h[1];
def loDiff = l[1] - l;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR2 = WildersAverage(TrueRange(h, c, l), 14);
def "DI+" = 100 * WildersAverage(plusDM, 14) / ATR2;
def "DI-" = 100 * WildersAverage(minusDM, 14) / ATR2;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-" ) / ("DI+" + "DI-" ) else 0;
def SymbolADX = WildersAverage(DX, 14);

def ADXred = if SymbolADX <= 20 then 1 else 0;
def ADXgreen = if SymbolADX > 20 then 1 else 0;

AddLabel(ADXred and SymbolADX < SymbolADX[1], Round(SymbolADX, 0) + "<", Color.DOWNTICK);
AddLabel(ADXred and SymbolADX > SymbolADX[1], Round(SymbolADX, 0) + ">", Color.DOWNTICK);
AddLabel(ADXgreen and SymbolADX < SymbolADX[1], Round(SymbolADX, 0) + "<", Color.UPTICK);
AddLabel(ADXgreen and SymbolADX > SymbolADX[1], Round(SymbolADX, 0) + ">", Color.UPTICK);



Edited 2 time(s). Last edit at 12/31/2015 01:44PM by tanman.
Re: Fun with ThinkScript
January 01, 2016 03:47PM
Tanman,

Thank you very much..You are a beast. The script looks great. Is there a way I can run your script as a scan as well
Ed
Re: Fun with ThinkScript
January 04, 2016 05:00PM
Kamadi:

Would you mind sharing your strategy on how you would trade off of these indicators?

Thanks.
Re: Fun with ThinkScript
January 04, 2016 06:57PM
Can anyone please help me to put below logic in script

A=Count Dow Jones Industrial average stock Net Change $0.94 or above
B=Count Dow Jones Industrial average stock Net Change $-0.94 or below

Results1 =A-B

Then whatever the results (Plus or Minus)

Results2 = Results1 * 2
Results3 = Results1 * 20

If results2 is greter than /ES mini 500 future Net change then Put label on chart "Overbought" in Red color
If results3 is greter than /YM Mini Dow future Net change then Put label on chart "Overbought" in Red color


If results2 is equal /ES mini 500 future Net change then Put label on chart "Neutral " in gray color
If results3 is equal /YM Mini Dow future Net change then Put label on chart "Neutral " in gray color


If results2 is less than /ES mini 500 future Net change then Put label on chart "Oversold " in Green color
If results3 is less than /YM Mini Dow future Net change then Put label on chart "Oversold " in Green color


If results2 is greater / less than 7 points of /ES mini 500 future Net change then Put label on chart "Extreme overbought/Oversold " in Red/Green color
If results3 is greater /less than 140 points of /YM Mini Dow future Net change then Put label on chart "Extreme overbought/Oversold " in Red/Green color


Can anyone please help on this

this script will help to track future market with cash market
Re: Fun with ThinkScript
January 05, 2016 10:00AM
Hello, I would like to know if anybody can help me. I've purchased Robert reversal scan months ago, I am getting a lot of tickers but always late when a reversal happened. Is there any way i can get an alert on the watchlist when all the criteria are met ?. thank you
Re: Fun with ThinkScript
January 05, 2016 10:20AM
Tanman,

On trade today on LVS entry 10:00 at 43.61 Ist target 43.76 and second target 43.91. If I did it correctly profit was $225 with $150 risk. Is that what you get? Just testing code.



Edited 2 time(s). Last edit at 01/07/2016 07:30AM by robertc777.
Sorry, only registered users may post in this forum.

Click here to login