Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10:35 optntradrsuntd: It signals green/red based on the breakout/breakdown which is good, but it's just fine tuning the areas where you shouldn't be in the trade
- 10:42 Nube: Rewrite the assignpricecolor statement to have the 3 conditions you want. It won't change to users preference.
- 10:43 Nube: As is there is no condition that would make it apply the "neutral" color
- 10:44 Nube: harumph, wrong I am. Should have looked closer.
- 10:45 Nube: You will still need to rewrite the the statement to make it do what you want instead of what it's scripted to do currently.
- 10:46 optntradrsuntd: Oh man
- 10:46 Nube: Not nearly as tough as it may seem.
- 10:48 optntradrsuntd: It's all the same, except it's giving signals off the EMA's disregarding price action
- 10:48 optntradrsuntd: And that's out of my realm, I just spotted the weakness in it, I don't know how to change it
- 10:51 Nube: start with definitely the price action
- 10:53 Paris: optntradrsuntd - Here is a real simple snippet to do what you wish. It colors candles YELLOW if between MA8-13, WHITE if between MA13-21, and PINK otherwise). Note this is a standalone study, so you'll need to do some work to fit this back into Slim's study
- plot MA8 = ExpAverage(close, 8);
- plot MA13 = ExpAverage(close, 13);
- plot MA21 = ExpAverage(close, 21);
- AssignPriceColor(if between(close, MA8, MA13) then Color.YELLOW
- else if between(close, MA13, MA21) then Color.WHITE
- else Color.PINK);
- 10:54 optntradrsuntd: Awesome, thank you very much
- 10:56 optntradrsuntd: Curious about the pink
- 11:00 AlphaInvestor: I am curious about a lot of things but not color names
- 11:03 optntradrsuntd: I'm a newbie, I'm curious about all of it lol
- 11:04 optntradrsuntd: Like I know what I'mn looking for in the code, but I don't know how to modify it enough or start with what I'm trying to do. Slims study has a simliar concept, it just relies on the EMA's positioning over each other
- 11:13 linas: random message from me here....
- 11:14 MTS1: Optn; to understand the code make sure to use the reference as you're reviewing or writing code. Also read the thinkscript tutorials as a great place to get started. Both are at http://tlc.thinkorswim.com/. Reviewing existing scripts, built-in or custom, like you're doing now is a great way to learn also, but helps to have read the tutorials and they are not long.
- 11:14 linas: you can do a lot more logistically, and set auto trades rather easy
- 11:14 Vimes: linas, bad form to discuss other platforms
- 11:15 linas: sorry
- 11:15 linas: i do LOVE Tda
- 11:15 linas: to be fair
- 11:15 linas: i just see this "I'm looking to do this, how I do it" questions a lot
- 11:15 harndog: To be fair, your posting in TDA forum, run by TDA, and your acknowledge TDA rules.
- 11:16 linas: and Mobius and the rest of the crew are awesome to help
- 11:16 linas: just saying.. wish it used C# or C++, to go to next level
- 11:16 linas: but fair enough, it has amazing library of built in code, and noone can match that
- 11:17 linas: have a good day everyone !
- 11:17 MTS1: Hope they have a useful lounge also;)
- 11:17 harndog: +1
- 11:32 optntradrsuntd: Paris - I have the script in, everything is good up until the 8 EMA.
- So if price is above the 8 EMA = green
- if price is below 8 EMA = red
- But to still hold the corresponding colors when price action is between certain EMA's
- 11:53 MTS1: believe that is color.current
- 11:56 Blue_Oyster_Cult-: optntradrsuntd: #start
- #hint: b>Ask SLM Ribbon
- thank you for the post ...........
- 12:01 Nube: re languages other than ThinkScript, I'm extremely thankful this is in ThinkScript. I'd have never learned nor been involved here at all for that matter if it was a different language
- 12:04 optntradrsuntd: No problem Blue, trying to get some fine tuning done to it
- 12:08 RKX1: Grid_20180828_2
- 12:11 RKX1: http://tos.mx/rcbmch
- 12:12 optntradrsuntd: ?
- 12:20 optntradrsuntd: So thinkscript is it's own language in a sense? Or is it variations of all the coding languages?
- 12:20 optntradrsuntd: Or varations of some*
- 12:21 AlphaInvestor: thinkScript is it own language
- 12:21 MTS1: variation of JavaScript
- 12:22 MTS1: Or Java (not a programmer) TOS is written in Java and TS was a derivative written by it's programmers.
- 12:22 MTS1: or using the same structure anyways. .
- 12:30 Geeha: I would like to install two filters into my chart. The first is to scan the S&P500 for all stocks after market close that have two bars above a ten period moving average High and those two bars highlighted in light green. The second is to scan the S&P500 for all stocks after market close that have two bars below an eight period moving average Low and those two bars highlighted in light red. If you can take me through the steps to do this I would greatly appreciate it! Thank You
- 12:36 AlphaInvestor: you are asking for 2 things - a Scan and a companion Chart
- 12:38 Vimes: the scan part is going to return too many hits to be useful imo
- 12:38 AlphaInvestor: Vimes - agreed
- 12:41 Vimes: Geeha, you can try something like this to get you started - but you will need to add some additional criteria: put this in a custom scan of the S&P500 watchlist
- def cond1 = close>simpleMovingAvg(high,8)[1];
- plot scan = sum(cond1,2)==2;
- 12:52 AlphaInvestor: Amalia - CAHOLD column
- # CAHOLD Bull Flag Watchlist Column
- # 7.17.2018
- # [email protected] CAHOLD Search
- # To use for scan place # signs before Addlabel statement and change "def" before trigger statement to "plot"
- #14:10 Mobius: The Mr. Script Replacement or Mr. Script Redux didn't explain that the reason MACD is used in his study to identify flags is that MACD shows divergence, squeeze, price compression fairly well. If price is rising and MACD is not that is the reason.
- input PriceOfStock = 10;#Default 10
- input BullFlagWithinHowManyDays = 1; #Default 1
- input SensitivityMALength = 30; #Default 30
- input SMAlookback = 5;#Defaqult 5
- def StockPrice = close >=PriceOfStock;
- def trend = simpleMovingAvg("length"=SensitivityMALength)> simpleMovingAvg("length"=SensitivityMALength)[SMAlookback];
- def MacdLow = macdHistogram(8,17,9)[1]< macdHistogram(8,17,9)[2]and close[1]<close[2] and close>high[1];
- #def Momentum = macdHistogram(8,17,9) > macdHistogram(8,17,9)[1];
- #def trigger = trend and momentum and MacdLow;
- def trigger = trend and MacdLow;
- AddLabel(yes, if trigger within BullFlagWithinHowManyDays bar then "Bull Flag" else " ",Color.PLUM);
- AssignBackgroundColor(if trigger then color.YELLOW else color.WHITE);
- 12:56 optntradrsuntd: Is that the whole code Mobius? I use MACD a lot, would like to test it out
- 12:56 amalia: Thanks, Ai.
- 12:57 fifotrader: Mobius Can you help me with how to determine the following:
- Let’s say there are condition that causes a stock go up by 60 percent and another condition to make it go up 30 per cent.
- What is the per cent if both happen? Should it be more than 60 per cent? Or is it impossible since all possible conditions are not known?
- 12:57 amalia: eh
- 12:58 Farmin: go look up a compound interest equation
- 12:59 AlphaInvestor: yeah, it depends on whether they are subsequent moves, and which came first
- 13:01 Vimes: 1.6*1.3?
- 13:01 fifotrader: Let.s say they both happen at the same time.
- 13:02 Farmin: 1.6 * 1.3 = 1.3 * 1.6 assuming they are subsequent moves
- 13:03 Farmin: fifo, make it real start with a dollar. figure out what your question reeally is
- 13:04 AlphaInvestor: farmin - dats that new math isn't it
- 13:04 Farmin: yup it is
- 13:05 Vimes: well its one of the basic properties of multiplication so not relaly new math
- 13:05 Farmin: sure wish someone could splain it to me. and then probablilty density functions
- 13:06 Farmin: well, new math is kinda old now
- 13:06 AlphaInvestor: Vimss -1 ... your makin' me look bad
- 13:06 Vimes: lol
- 13:06 Vimes: sorry - ;)
- 13:12 mthfr_vaxxed: per cent or percent? this a trick question?
- 13:14 Vimes: not sure; i also wasn't sure if there was more to the question - if you are saying the outcome is random you would need to provide a probability of the events occurring
- 13:15 amalia: lol mth
- 13:19 Anonymous so far: What u think about AMD
- 13:20 AlphaInvestor: Wrong chat room
- 13:25 fifotrader: I have been trying to figure this out for some time.
- To determine a probability occurrence you record all occurrences of a condition and divide it by all possible occurrences.
- So I guess this can’t be solved?`
- 13:26 optntradrsuntd: a bell curve
- 13:27 AlphaInvestor: fifo - what you describe can be solved
- 13:27 fifotrader: how
- 13:27 AlphaInvestor: count all the times it occurred on the chart, divide by the number of bars on the chart - easy peasy
- 13:28 optntradrsuntd: That's the best way tbh, don't need a code for that
- 13:31 fifotrader: Alpha- you are right- but I do not have that data I just have the percent's
- 13:32 optntradrsuntd: If you have the percentages already what are you looking for?
- 13:33 fifotrader: What happen when they both occur
- 13:33 AlphaInvestor: Fifo - you can calculate that data from the chart
- 13:34 Vimes: fifo can you describe exactly what you are struggling to do - seems very vague atm
- 13:35 AlphaInvestor: are you looking for the number of times that a 60% move on day 1 ... is followed by a 30% move on day 2?
- 13:35 AlphaInvestor: or are you looking for the number of times that there is a total move of 90% over a 2 day period?
- 13:35 AlphaInvestor: we have no idea what your question is
- 13:35 Vimes: ^
- 13:38 fifotrader: I have info that a pattern
- 13:38 fifotrader: sorry not do i
- 13:41 optntradrsuntd: Take a minute, recollect and explain what you are trying to do
- 13:50 fifotrader: I have data that a stock goes up let’s say 60% with a candle pattern.
- I also know that the stock go up let’s 40% during the first week September.
- What is the probability of the stock going up?
- 13:51 optntradrsuntd: There are countless variables to why the stock would be going up
- 13:51 Nube: Does that percent with a pattern include that period of September?
- 13:51 optntradrsuntd: earnings/good news etc
- 13:52 fifotrader: give up
- 13:52 optntradrsuntd: Bullflag patterns have hige probabilities of breaking out etc
- 13:52 optntradrsuntd: high*
- 13:52 AlphaInvestor: Fifo - 50%
- 13:52 Vimes: fifo - what you are asking is possible but you have to define the problem for us to help you
- 13:53 Vimes: otherwise 50% is the best estimate which would put you around 45% return
- 13:53 cattle_trader: how would i code to have a moving average + so many tiks = sell and vise versa?
- 13:53 fifotrader: Alpha that is what I keep coming up with but I am not sure?
- 13:54 AlphaInvestor: without more information you have a 50% chance of going up, a 50% chance of going down - prices are RANDOM
- 13:54 optntradrsuntd: ^
- 13:54 Vimes: if both are independent - define the candle pattern and observe the number of roc occurencesn in your defined timeframe. this is probablity 1
- 13:54 Farmin: past performance is not indicative of future results
- 13:55 optntradrsuntd: performance, not of patterns
- 13:55 AlphaInvestor: The chances of a 60% move up, followed by a 30% move up the next day are so infintessimally small that I would ignore that chance
- 13:56 Vimes: if you are looking for back data on candlestick patterns check bulkowski site
- 13:56 optntradrsuntd: H&S formations are high probability trades too
- 13:56 optntradrsuntd: like 55-60% I believe, may be slightly higher
- 13:58 AlphaInvestor: Bull market resutls for H&S tops
- "Percentage meeting price target: 55%"
- 13:59 Vimes: and if anything was so obvious as buying in september would give you a 40% return everyone would be filfthy rich
- 13:59 RayK: Today is Mr Script day. Every Tuesday at 5:30 EDT, Ken Rose does the Mr Script Thinkscript tutorial Webcast. This week, Ken will finish a multisession discussion and demonstration of TOS Strategies. TOS Strategies are a simple but effective backtesting system. These tutorials and demonstrations are not to be missed! The Mr Script Webcast is at 5:30 EDT Tuesdays and can be found either in the Thinkscript Lounge (click Watch) - close the room and reopen it no more than 10 minutes before 5:30 EDT. Or, on the Web at https://events.thinkorswim.com/#/webcast - Login no more than 10 minutes in advance of the session.
- 14:00 mthfr_vaxxed: thanks RayK
- 14:02 cattle_trader: nobody?
- 14:02 fifotrader: Vimes not 40% return 40% probability
- 14:03 fifotrader: big difference
- 14:03 Vimes: 0.5*0.6+0.5*0.3=0.45
- 14:03 Vimes: you have to define the probability - withou more information they are 50%
- 14:03 optntradrsuntd: There is a higher probability that if a stock makes an extreme move that the following day it will revert back to the mean
- 14:04 fifotrader: you would have 60% chance of losing
- 14:04 AlphaInvestor: This converstaion is going in circles - it needs to stop, I am getting dizzy
- 14:04 optntradrsuntd: See why not really following why you want to figure this out, it's very small chance that you'd be right
- 14:06 Vimes: agree with alpha you orig said a 60% return and 30% return for two separate occurences without mention of probability - unless you are going to define the probelm further as a thinkscript questino suggest we drop it
- 14:06 mthfr_vaxxed: "Fooled by Randomness" is a good read
- 14:07 mthfr_vaxxed: kinda.... could have rambled less. but still good info.
- 14:09 AlphaInvestor: I haven't read that one, but this one is an excellent book
- "A Random Walk Down Wall Street"
- 14:09 Vimes: i don't agree with pure random price - if that was the case and there wasn't a p[ositive expectancy we wouldn't have a market
- 14:09 FrankB3: I have that book
- 14:10 mthfr_vaxxed: false positives probablity question : if test for disease is 90% accurate and disease effects 1 in 10,000 people... if you test positive what is the chance you have disease? hint: its not 90%
- 14:10 mthfr_vaxxed: i have that one Alpha. next on my reading list. need to get that started after i finishing sending resumes everywhere and doing stupid coding challenges.... ugh
- 14:12 Nube: .9/10,000 seems like a small number
- 14:12 mthfr_vaxxed: and no one agrees with a completely random price... the point is if you can account for that you can acocunt for anythihng
- 14:12 mthfr_vaxxed: ie. Monte Carlo simulation
- 14:13 mthfr_vaxxed: just like no one should agree with a completely rational market either... (**cough** Long Term Capital Management **cough** )
- 14:14 mthfr_vaxxed: "When Genius Failed" for that blunder
- 14:15 mthfr_vaxxed: because..... people are not rational or random. a drunk sailor is headed somewhere.. we can all guess
- 14:16 mthfr_vaxxed: class dismissed.
- 14:16 optntradrsuntd: *bell rings* lol
- 14:17 optntradrsuntd: There was a code shared from here a while back that shows trends based off a ATR, with targets on each side. That has been the best study I've used. Whoever made it, if you are here, thank you
- 14:19 optntradrsuntd: #ATRTrailingStop_ATR_Method_Only_MTF Script (referred to as ATR hereafter)
- #Volume Profile option will display a new volume profile at each change of state in the ATRTrailingStop indicator
- input showvolumeprofile = yes;
- input stopmethod = {default atr, custom};
- input usehigheraggperiod = {default "Current", "Higher"};
- input agg = AggregationPeriod.TWO_MIN;
- input atraveragetype = averageType.WILDERS;
- input outputformat = {default Rounded, "Not Rounded"};#Hint outputformat: 'Not Rounded' is used for notes, bonds (eg: 109'110), forex, etc type format.
- input usealerts = no;
- input target1 = 1.5;#Hint target1: number times entry - stop
- input target2 = 3.0;#Hint target2: number times entry - stop
- input trailType = {default modified, unmodified};
- input ATRPeriod = 5;
- input ATRFactor = 1.618;
- input firstTrade = {default long, short};
- def c;
- def l;
- def h;
- def o;
- def error = usehigheraggperiod == usehigheraggperiod."Higher" and GetAggregationPeriod() > agg;
- switch (usehigheraggperiod) {
- case Current:
- c = close;
- l = low;
- h = high;
- o = open;
- case Higher:
- if error {
- o = Double.NaN;
- h = Double.NaN;
- l = Double.NaN;
- c = Double.NaN;
- } else {
- c = close(period = agg);
- l = low(period = agg);
- h = high(period = agg);
- o = open(period = agg);
- }
- }
- def HiLo = Min(h - l, 1.5 * Average(h - l, ATRPeriod));
- def HRef = if l <= h[1]
- then h - c[1]
- else (h - c[1]) - 0.5 * (l - h[1]);
- def LRef = if h >= l[1]
- then c[1] - l
- else (c[1] - l) - 0.5 * (l[1] - h);
- def ATRMod = ExpAverage(Max(HiLo, Max(HRef, LRef)), 2 * ATRPeriod - 1);
- def trueRange;
- switch (trailType) {
- case modified:
- trueRange = Max(HiLo, Max(HRef, LRef));
- case unmodified:
- trueRange = TrueRange(h, c, l);
- }
- def loss = ATRFactor * MovingAverage(atraverageType, trueRange, ATRPeriod);
- def state = {default init, long, short};
- def trail;
- switch (state[1]) {
- case init:
- if (!IsNaN(loss)) {
- switch (firstTrade) {
- case long:
- state = state.long;
- trail = c - loss;
- case short:
- state = state.short;
- trail = c + loss;
- }
- } else {
- state = state.init;
- trail = Double.NaN;
- }
- case long:
- if (c > trail[1]) {
- state = state.long;
- trail = Max(trail[1], c - loss);
- } else {
- state = state.short;
- trail = c + loss;
- }
- case short:
- if (c < trail[1]) {
- state = state.short;
- trail = Min(trail[1], c + loss);
- } else {
- state = state.long;
- trail = c - loss;
- }
- }
- plot TrailingStop = trail;
- TrailingStop.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
- TrailingStop.DefineColor("Buy", GetColor(0));
- TrailingStop.DefineColor("Sell", GetColor(1));
- TrailingStop.AssignValueColor(if state == state.long
- then TrailingStop.Color("Sell")
- else TrailingStop.Color("Buy"));
- TrailingStop.HideBubble();
- #Horizontals are used to determine color of price bars
- input showhorizontals = no;
- def HAclose = (o + h + l + c) /4;
- def HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
- def HAhigh = Max( h, Max( HAopen, HAclose ) );
- def HAlow = Min( l, Min( HAopen, HAclose ) );
- def hamid = (haHigh + haLow) / 2;
- def horizontall = if state != state[1] and state == state.long
- then hamid
- else horizontall[1];
- plot horizontallow = horizontall;
- horizontallow.SetPaintingStrategy(PaintingStrategy.DASHES);
- horizontallow.SetDefaultColor(Color.GREEN);
- horizontallow.SetHiding(!showhorizontals);
- def horizontalh = if state != state[1] and state == state.short
- then hamid
- else horizontalh[1];
- plot horizontalhigh = horizontalh;
- horizontalhigh.SetPaintingStrategy(PaintingStrategy.DASHES);
- horizontalhigh.SetDefaultColor(Color.RED);
- horizontalhigh.SetHiding(!showhorizontals);
- #Price Bar Coloring - Green=Up; Red=Down; White=Warning, no direction determined by horizontals. Look for green/red bars above/below entry for better signal. White bars pulling back to trailing stop followed by a colored bar(s) in direction of ATR may be a good entry
- input pricecolor = yes;
- AssignPriceColor(if pricecolor
- then if state == state.long and c > horizontall and l > trail
- then Color.GREEN
- else if state == state.short and c < horizontalh and h < trail
- then Color.RED
- else Color.WHITE
- else Color.CURRENT);
- #Counter - Displays a bubble at last bar printed of the number of bars at a particular color
- def greencount = if state == state.long and c > horizontall
- then (greencount[1] + 1)
- else 0;
- def redcount = if state == state.short and c < horizontalh
- then (redcount[1] + 1)
- else 0;
- def whitecount = if greencount == 0 and redcount == 0
- then (whitecount[1] + 1)
- else 0;
- input showcolor_counting_bubble = yes;
- AddChartBubble(showcolor_counting_bubble and IsNaN(close[-1]) and !IsNaN(close) and greencount > 0,
- low, greencount, Color.GREEN , no);
- AddChartBubble(showcolor_counting_bubble and IsNaN(close[-1]) and !IsNaN(close) and redcount > 0,
- low, redcount , Color.RED , no);
- AddChartBubble(showcolor_counting_bubble and IsNaN(close[-1]) and !IsNaN(close) and greencount == 0 and redcount == 0,
- low, whitecount, Color.WHITE, no);
- def BuySignal = if Crosses(state == state.long, 0, CrossingDirection.ABOVE)
- then 1
- else Double.NaN;
- def SellSignal = if Crosses(state == state.short, 0, CrossingDirection.ABOVE)
- then 1
- else Double.NaN;
- def condup = !IsNaN(BuySignal);
- def conddn = !IsNaN(SellSignal);
- def condu = if !IsNaN(c) and condup == 1
- then BarNumber()
- else condu[1];
- def condd = if !IsNaN(c) and conddn == 1
- then BarNumber()
- else condd[1];
- #Entry plot is based upon the high/low of the signal bar or the prior bar (use input entrybars as "0" for just the signal bar or "1" for high/low of the signal or next bar)after the buysignal or sellsignal was met. The entry bubble will change from white to green/red when the high/low breaks the entry value. You will need to change the code if you want to use another basis.
- plot entry = if BarNumber() >= Max(HighestAll(condu), HighestAll(condd))
- then if condu > condd
- then HighestAll(if BarNumber() == HighestAll(condu)
- then Max(h, h[1])
- else Double.NaN)
- else HighestAll(if BarNumber() == HighestAll(condd)
- then Min(l, l[1])
- else Double.NaN)
- else Double.NaN;
- #Initial Stop
- #Choose the initial stop method, either the change of the ATR or a custom method of your choosing. The custom initial stop is based upon a lookback from when the buysignal or sellsignal is met. Since these buysignals or sellsignals can change based on the 2nd condition while the atrtrailingStop method does not, then custom initial stop may provide better targets. The lookback length can be changed at the input screen.
- input stoplookback = 3;
- def atrinitialstop = if state != state[1]
- then trail
- else atrinitialstop[1];
- def atrintstopext = if IsNaN(c) then atrintstopext[1] else atrinitialstop;
- plot stop = if IsNaN(entry)
- then Double.NaN
- else if stopmethod == stopmethod.atr
- then if BarNumber() >= Max(HighestAll(condu), HighestAll(condd))
- then atrintstopext
- else Double.NaN
- else if BarNumber() >= Max(HighestAll(condu), HighestAll(condd))
- then if condu > condd
- then HighestAll(if BarNumber() == HighestAll(condu)
- then Lowest(l, stoplookback)
- else Double.NaN)
- else HighestAll(if BarNumber() == HighestAll(condd)
- then Highest(h, stoplookback)
- else Double.NaN)
- else Double.NaN;
- #Trailing Stop uses the current position of the ATR's "trail" variable
- plot atrstop = if IsNaN(entry)
- then Double.NaN
- else if BarNumber() < Max(HighestAll(condu), HighestAll(condd))
- then Double.NaN
- else HighestAll(if IsNaN(c[-1]) and !IsNaN(c)
- then trail
- else Double.NaN);
- #Alerts - The alerts can be turned on/off at the input screen.
- Alert(usealerts and c crosses entry, "Entry " + c, Alert.BAR, Sound.Chimes);
- #Targets - These are based upon the difference between the entry price and the initial stop of your choice, multiplied by then variables that you input below. The targets will be displayed in lines and bubbles, which will change from a light color to green when the target is met.
- plot t1 = if IsNaN(entry) then Double.NaN
- else if condu > condd
- then (entry + (entry - stop) * target1)
- else (entry - (stop - entry) * target1);
- plot t2 = if IsNaN(entry) then Double.NaN
- else if condu > condd
- then (entry + (entry - stop) * target2)
- else (entry - (stop - entry) * target2);
- #Plot Look and Feel
- entry.SetDefaultColor(Color.WHITE);
- stop.SetDefaultColor(Color.RED);
- t1.SetDefaultColor(Color.WHITE);
- t2.SetDefaultColor(Color.WHITE);
- entry.HideBubble();
- stop.HideBubble();
- t1.HideBubble();
- t2.HideBubble();
- atrstop.HideBubble();
- atrstop.SetLineWeight(1);
- atrstop.AssignValueColor(if HighestAll(if IsNaN(c[-1]) and !IsNaN(c) and c > atrstop
- then 1
- else 0) == 1
- then Color.GREEN
- else Color.RED);
- #ATR Trailing Stop Long/Short (shown as Green/Red) Bubble in expansion denotes current status of ATRTrailingStop indicator
- input showbubble_indicator = no;
- input bubblemover_indicator = 20;#Hint bubblemover_indicator: = number of spaces to move atrtrailingstop indicator bubble sideways
- def z = bubblemover_indicator;
- def z1 = z + 1;
- input bubblealign = .00;
- AddChartBubble(showbubble_indicator and IsNaN(c[z]) and !IsNaN(c[z1]),
- c[z1] - bubblealign,
- "A",
- if state[z1] == state.long
- then Color.GREEN
- else Color.RED);
- #Trailing Stop Bubble
- input bubblemover_trailingstop = 2;#Hint bubblemover_trailingstop: = number of spaces to move trail stop bubble sideways
- def s = bubblemover_trailingstop;
- def s1 = s + 1;
- AddChartBubble(IsNaN(c[s]) and !IsNaN(c[s1]),
- atrstop[s1],
- "Trail \n" + (if outputformat == outputformat."Not Rounded"
- then AsPrice(trail[s1])
- else AsText(Round(trail[s1], 2))),
- if HighestAll(if IsNaN(c[s]) and !IsNaN(c[s1]) and c[s1] > atrstop[s1]
- then 1
- else 0) == 1
- then Color.GREEN
- else Color.RED,
- if condu[s1] > condd[s1]
- then no
- else yes);
- #Entry Bubble - Will turn green or red if entry is exceeded
- input bubblemover_entry_stop_targets = 8;#Hint bubblemover_entry_stop_targets: = number of spaces to move entry, initial stop and target bubbles sideways
- def n = bubblemover_entry_stop_targets;
- def n1 = n + 1;
- def eup = if condu > condd and h > entry
- then 1
- else if eup[1] == 1 and condu > condd
- then 1
- else 0;
- def edn = if condu < condd and l < entry
- then 1
- else if edn[1] == 1 and condu < condd
- then 1
- else 0;
- AddChartBubble(IsNaN(c[n]) and !IsNaN(c[n1]),
- entry[n1],
- "Entry: " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(entry[n1])
- else AsText(Round(entry[n1], 2))),
- if !IsNaN(eup[n1]) == 1
- then Color.GREEN
- else if !IsNaN(edn[n1]) == 1
- then Color.RED
- else Color.WHITE);
- #Stop Bubble
- AddChartBubble(IsNaN(c[n]) and !IsNaN(c[n1]),
- stop[n1],
- "Stop: " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(stop[n1])
- else AsText(Round(stop[n1], 2))),
- Color.RED);
- #Targets
- #Defining when targets are met
- def t1ru = if condu > condd and
- h > t1
- then 1
- else if t1ru[1] == 1 and condu > condd
- then 1
- else 0;
- def t2ru = if condu > condd and
- h > t2
- then 1
- else if t2ru[1] == 1 and condu > condd
- then 1
- else 0;
- def t1rd = if condu < condd and
- l < t1
- then 1
- else if t1rd[1] == 1 and condu < condd
- then 1
- else 0;
- def t2rd = if condu < condd and
- l < t2
- then 1
- else if t2rd[1] == 1 and condu < condd
- then 1
- else 0;
- #Target Bubbles - Green if Target Hit, Light_Gray otherwise
- AddChartBubble(IsNaN(c[n]) and !IsNaN(c[n1]),
- t1[n1],
- "T1 " +
- ": " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(t1[n1])
- else AsText(Round(t1[n1], 2))) +
- " " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(AbsValue(t1[n1] - entry[n1]))
- else AsText(AbsValue(Round(t1[n1], 2) - Round(entry[n1], 2)))),
- if !IsNaN(t1ru[n1]) == 1 or !IsNaN(t1rd[n1]) == 1
- then Color.GREEN
- else Color.LIGHT_GRAY);
- AddChartBubble(IsNaN(c[n]) and !IsNaN(c[n1]),
- t2[n1],
- "T2 " +
- ": " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(t1[n1])
- else AsText(Round(t2[n1], 2))) +
- " " + (if outputformat == outputformat."Not Rounded"
- then AsPrice(AbsValue(t2[n1] - entry[n1]))
- else AsText(AbsValue(Round(t2[n1], 2) - Round(entry[n1], 2)))),
- if !IsNaN(t2ru[n1]) == 1 or !IsNaN(t2rd[n1]) == 1
- then Color.GREEN
- else Color.LIGHT_GRAY);
- #
- # TD Ameritrade IP Company, Inc. (c) 2010-2016
- #
- input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
- input customRowHeight = 1.0;
- input onExpansion = no;
- input profiles = 1000;
- input showPointOfControl = yes;
- input showValueArea = yes;
- input valueAreaPercent = 70;
- input opacity = 50;
- def cond = state[1]!= state;
- def height;
- switch (pricePerRowHeightMode) {
- case AUTOMATIC:
- height = PricePerRow.AUTOMATIC;
- case TICKSIZE:
- height = PricePerRow.TICKSIZE;
- case CUSTOM:
- height = customRowHeight;
- }
- profile vol = volumeProfile("startNewProfile" = if showvolumeprofile then cond else double.nan, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = if showvolumeprofile then valueAreaPercent else double.nan);
- def con = compoundValue(1, onExpansion, no);
- def pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
- def hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
- def lVA = if IsNaN(vol.getLowestValueArea()) and con then lVA[1] else vol.getLowestValueArea();
- def hProfile = if IsNaN(vol.getHighest()) and con then hProfile[1] else vol.getHighest();
- def lProfile = if IsNaN(vol.getLowest()) and con then lProfile[1] else vol.getLowest();
- def plotsDomain = IsNaN(close) == onExpansion;
- plot POC = if plotsDomain then pc else Double.NaN;
- plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
- plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
- plot VAHigh = if plotsDomain then hVA else Double.NaN;
- plot VALow = if plotsDomain then lVA else Double.NaN;
- DefineGlobalColor("Profile", GetColor(1));
- DefineGlobalColor("Point Of Control", GetColor(5));
- DefineGlobalColor("Value Area", GetColor(8));
- vol.Show(Color.CURRENT, if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
- POC.SetDefaultColor(globalColor("Point Of Control"));
- POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
- VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
- VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
- VAHigh.SetDefaultColor(globalColor("Value Area"));
- VALow.SetDefaultColor(globalColor("Value Area"));
- ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
- ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
- ProfileHigh.SetDefaultColor(GetColor(3));
- ProfileLow.SetDefaultColor(GetColor(3));
- ProfileHigh.hide();
- ProfileLow.hide();
- input showbubbleperperiod = no;
- input bubblemoverperperiodhorizontal = 3;
- input bubblemoverperperiodvertical = 2;
- def bubble = if state[1] != state
- then BarNumber() + bubblemoverperperiodhorizontal
- else bubble[1];
- AddChartBubble(showbubbleperperiod and BarNumber() == (bubble),
- profilehigh + bubblemoverperperiodvertical * TickSize(),
- (VAHigh - VALow),
- Color.GRAY, yes);
- 14:21 AJayKC: hi i need help please. I was trying to create a simple colored label with spyticker symbol to put on my chart. for thich it will have green color it the last price is above closing price and red label if last price is below previous closing price.
- 14:21 AJayKC: input SYMB = " SPY ";
- def AD = close(symbol = SYMB);
- AddLabel(1, " SPY " + SYMB + " = " + AD, if close < Average(close,1) then color.green else color.red);
- 14:21 AJayKC: what am i missing?
- 14:23 AJayKC: any help or suggestion is much appreciated. thanks.
- 14:26 Vimes: se if this works:
- input SYMB = "SPY";
- def AD = close(symbol = SYMB);
- AddLabel(1,SYMB + " = " + AD, if AD > AD[1] then color.green else color.red);
- 14:27 AJayKC: ok let me try thank you.
- 14:33 FrankB3: 15:19 optntradrsuntd: #ATR: you can ask Kuba where he got if from:: seems similar :: http://tos.mx/FyhHJF
- 14:35 AJayKC: looks like its working. thanks vimes. i just wanted to makes sure if its giving green label if current price > previous day's close price? or previous candle?
- 14:36 optntradrsuntd: That is exactly it Frank haha
- 14:36 Vimes: np, if that's a question that is what the AD>AD[1] is doing
- 14:36 Nube: bubblemover makes me think that's a BLT script.
- 14:36 optntradrsuntd: Modified it slightly to 1.41, better results for scalping
- 14:37 AlphaInvestor: That ATR study is from BLT, I don't know why he didn't put his name in it
- 14:37 AJayKC: current price > previous day's close?
- 14:38 Nube: Is there any script Frank doesn't have?
- 14:38 amalia:
- #amalia - OpenClose stats
- def A = AggregationPeriod.DAY;
- def T = TickSize();
- def N = Double.NaN;
- def B = BarNumber();
- input showLabels = YES;
- input sLength = 10;
- def C = close(period = A)[1];
- def O = open(period = A)[1];
- def L = low(period = A)[1];
- def H = high(period = A)[1];
- # Labels only good for Daily aggregation
- def countUp = if C[1] > O[1] and C > O
- then countUp[1] + 1
- else countUp[1];
- def Pup = (B - countUp) / B;
- AddLabel(showLabels, " %PrevC > PrevO and C > O = " + AsPercent(Pup) + " | Happenstance = " + AsPercent(countUp / B) + " or " + countUp + " out of " + B ,
- Color.BLUE);
- def countDn = if C[1] < O[1] and C < O
- then countDn[1] + 1
- else countDn[1];
- def Pdn = (B - countDn) / B;
- AddLabel(showLabels, " %PrevC < PrevO and C < O = " + AsPercent(Pdn) + " | Happenstance = " + AsPercent(countDn / B) + " or " + countDn + " out of " + B ,
- Color.DARK_GREEN);
- def countR = if C[1] > O[1] and C < O
- then countR[1] + 1
- else countR[1];
- def Pr = (B - countR) / B;
- AddLabel(showLabels, " %PrevC > PrevO and C < O = " + AsPercent(Pr) + " | Happenstance = " + AsPercent(countR / B) + " or " + countR + " out of " + B ,
- Color.DARK_ORANGE);
- def countL = if C[1] < O[1] and C > O
- then countL[1] + 1
- else countL[1];
- def Pl = (B - countL) / B;
- AddLabel(showLabels, " %PrevC < PrevO and C > O = " + AsPercent(Pl) + " | Happenstance = " + AsPercent(countL / B) + " or " + countL + " out of " + B ,
- Color.GRAY);
- 14:38 AJayKC: thank you so much Vimes. i am really thankful that u took time to fix this .
- 14:38 Vimes: Ajay, if you are on a daily chart yes
- 14:38 AJayKC: i was on 5min chart
- 14:38 Vimes: if you are on a intraday chart you would have to add something else for the daily agg
- 14:39 Nube: amalia, thank you. I will be stealing that.
- 14:40 AJayKC: ok what would i have to add?
- 14:41 Vimes: input SYMB = "SPY";
- def AD = close(SYMB,aggregationPeriod.DAY);
- def c = close(SYMB);
- AddLabel(1,SYMB + " = " + c, if c > AD[1] then color.green else color.red);
- 14:41 Vimes: should work for intraday
- 14:42 AJayKC: thank you so much. u are awesome Vimes. God bless.
- 14:43 Vimes: np
- 15:46 twoshoes: Wow! 24 pages of buffer! Thank you, tculs
- 15:55 amalia: =)
- 16:11 optntradrsuntd: Amalia what is that study you shared? Not at the computer at the moment
- 16:11 optntradrsuntd: How is it best used
- 16:22 RayK: It is almost time for Mr. Script. The Mr Script Webcast is at 5:30 EDT Tuesdays and can be found either in the Thinkscript Lounge (click Watch) - close the room and reopen it no more than 10 minutes before 5:30 EDT. Or, on the Web at https://events.thinkorswim.com/#/webcast - Login no more than 10 minutes in advance of the session.
- 16:26 deucescooter: Does anybody have a script to ONLY show the extended hours trading Monkey Bars? Can it be done?
- 16:27 MTS1: Not via script; would be in settings if possible.
- 16:29 deucescooter: Can't figure out by settings. Of course you can get composite for extended and normal.
- 16:31 sugar: does anyone know how to write a scan on price average crossover, i want to be able to pick up all the stocks with green arrow up?
- 16:34 Farmin: something wrong with the built-in one?
- 16:34 sugar: never mind I figure it ouy
- 16:34 sugar: out
- 16:41 amalia: opt, just a code to show what happens with daily closes along with percentage and percentage of it happening
- 16:50 pom909090: Hi guys, I have a very interesting question would like to seek your help...
- 16:50 pom909090: I have used the default custom study script provided by TOS in Stock Hacker, namely "AfterHours_Percent_Change". I copied the script and paste it as custom Study under a chart.
- I found out that, the result of the Chart is DIFFERENT to the result from either the Scan or as a Watchlist column.
- For example - ticker FB:
- [Watchlist column]
- The calculated "closing price" from the script is 176.27, which is correct as the Prior day closing price for FB.
- [Chart]
- I copied the entire script into custom Chart, and created a Label output for "closing price". The result of "closing price" in the label is 172.9, which is the closing price around 4 trading days ago.
- Please assist...
- 16:56 AlphaInvestor: Thanks Ken!! - glad you are doing a deep dive on FOLD
- 16:59 Nube: Sure! It's a Fold session that would be the one I'd miss
- 17:00 pom909090: Sorry, please ignore my request. I found out that i iniitally used 5min chart, which will create this issue. If I changed to 1min chart, its fixed. Cheers guys!
- 17:06 amalia: Ok.
- 17:07 optntradrsuntd: Thanks amalia
- 17:33 ACE66: does anyone have any cup and handle codes?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement