Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Arizona times = CDT - 2 -- Arizona does not have Daylight Savings Time
- ------- Saturday, March 17, 2018 -------
- 08:05 MTS1: GM TCuls!
- 08:30 DougN: In applying the TOS PPS study to a watchlist and then creating a column to signal when the alert triggers, all seems to be working correctly. Can someone share how to apply color to the box in the watchlist column rather then the "1" and "0". This is the simple code for this watchlist column...IsNaN("value" = PPS().buysignal) is false. Thank you!
- 08:34 Jake-Elwood: you have 2 choices to color a watchlist column, either use a label and use its coloring or AddBackgroundColor
- 08:34 MTS1: Doug; use the AddLabel() function and put your formula in there
- 08:36 MTS1: Or AddBackgroundColor as Jake mentioned; the sort may be different; AddLabel sorts AlphaNumeric IIRC
- 08:36 Jake-Elwood: coloring logic looks like this:
- if <condition> then Color.GREEN else Color.RED
- 08:48 MTS1: yw. .
- 09:13 DougN: thanks very much guys...I will try to get these to work. These are very helpful skills that you have and hopefully someday Ill be able to apply more and help others as you are. Thank you!
- 09:13 AlphaInvestor: There is a third choice - coloring the text of a PLOT statement
- 09:13 AlphaInvestor: That will still sort correctly
- 09:48 Nube: Updated US Bond yield spread and curve script. Added an AD line for us bond yields since AD lines are all I've been doing lately
- 09:48 Nube: 
- 09:49 Nube: http://tos.mx/k8dImE
- 09:49 Nube: That version also has the Ten - One Spread which I don't believe the earlier version had. I added that because it has more history than the other spreads
- 09:50 MTS1: Cool Nube; thanks!
- 09:52 MTS1: I see you have the white border figured out. .
- 10:36 Nube: That line is the AD line for yield
- 10:36 Nube: Your chart weekly, Jake?
- 10:38 Jake-Elwood: was daily, now weekly. I now see same as your pic except for the dashed lines, they don't seem to be in this code
- 10:38 Nube: Oh, yeah, those were lines I was drawing when looking at charts
- 10:39 Nube: Didn't occur to me that I hadn't shared the change until after
- 10:39 Jake-Elwood: might want to add hide on intraday as the FRED data looks like only daily and above
- 10:42 Nube: Would be a good idea, which is why I won't
- 10:42 Jake-Elwood: heehee
- 10:59 amalia: lol
- 12:04 Y2K: .
- 12:07 momo: ..
- 12:11 technicaltraderoom: Hope everyone is well, quick question, how do I ignore 0 values when computing an average? I've done average(if number > 0 then number else no) but it still seems to count zeros in its computation.
- 12:26 DougN: Unfortunately I'm not able to get the code accepted by Thinkscript to colorize the PPS study column that I created. Thanks for everyones help but I've tried every combination I can ponder and can't get it operational. Can someone show me how it should be written in association with the existing script ...IsNaN("value" = PPS().buysignal) is false....to get it to colorize on a signal? Thank you!
- 12:26 MTS1: TT; need to explain more; 0 in the source data, or NaN? 0 in the Average? What would you plot instead on that bar; what would you want the value to be? No is a boolean; or in this case No = 0 as a value so it'd still count.
- 12:27 MTS1: What have you tried Doug? Did you find the functions in the manual with syntax details?
- 12:31 DougN: MTS1...is that where I find the "AdLabel" function? I was just trying the ...if condition> then Color.GREEN else Color.RED...but could not get anything there
- 12:31 MTS1: http://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel.html; what would you want to state in the column (text), and what color would you want it to be if buy signal is true or false; use Jake's syntax in the color variable; if <PPSbuysignal?> then Color.GREEN else Color.RED? What statement do you have and we can play with it. .
- 12:32 DougN: ahh...let me try that
- 12:32 MTS1: We already mentioned you can use AddLabel, AddBackgroundColor, or Plot; all are in the manual. Those are the only three that control color in a column, but plot is text color only
- 12:33 DougN:
- IsNaN("value" = PPS().buysignal) is false
- if <PPSbuysignal?> then Color.GREEN else Color.RED
- 12:33 MTS1: You can only have ONE eitther plot or addlabel in a column script.
- 12:33 MTS1: Where is the addlabel or alternative function?
- 12:35 DougN: I wil go to manual as I haven't done that yet. I want to learn.
- 12:36 DougN: Thank you for the input!
- 12:37 MTS1: that'd be the start if we point you to a function ;)
- 12:37 momo: technicaltraderoom when you say “else no” that is same as saying “else 0”
- 12:37 MTS1: Sample; no separate line needed for true / false determination: AddLabel(1,"TEXT", if IsNaN("value" = PPS().buysignal) then Color.GREEN else Color.RED);
- 12:37 momo: So you are letting 0 be still there
- 12:41 AlphaInvestor: No is a zero in binary/boolean
- 12:42 AlphaInvestor: Yes is a 1 ... athough many programming languages treat any non zero value as True or Yes
- 12:45 amalia: PPS sucks
- 12:45 amalia: kthxbye
- 12:46 AlphaInvestor: Any idea how to tell if it is Saturday or Sunday in TOS. Using
- def CurrentDOW = GetDayOfWeek(GetYYYYMMDD());
- returns 5 currently (Friday)
- 12:46 AlphaInvestor: likely because there is no bar today
- 12:47 DougN: MTS1...Should this be working? IsNaN("value" = PPS().buysignal) is false
- AssignBackgroundColor(if "value" = PPS().buysignal) then color.LIGHT_GREEN else color.BLACK);
- 12:47 amalia: Ai, I’m working on that right now. Haha Tell ya, everytime I’m working on something, someone in here is already on it
- 12:47 MTS1: Probably need to test in OnDemand? Wonder what it returns on Sunday when futures are open..
- 12:47 amalia: Tried ==7 to no avail either
- 12:48 amalia: Right. Aiming for Sunday open here
- 12:48 AlphaInvestor: MTS - that would probably depend on whether you had a /Futures symbol up
- 12:48 amalia: And don’t wanna input date function either. Too much work there
- 12:49 MTS1: your first line is not complete Doug; what variable are you populating?
- 12:49 AlphaInvestor: Doug - that should not work
- 12:49 AlphaInvestor: I suspect buysymbol would only ever by 1 or 0 - true or false ... never NaN
- 12:49 MTS1: you need to have an if statement in there somewhere
- 12:51 DougN: yes its true or false
- 12:51 MTS1: What is the rest of the statement; what value are you actually plotting to display in the cell?
- 12:51 DougN: IsNaN("value" = PPS().buysignal) is false
- AssignBackgroundColor(if "value" = PPS().buysignal) then color.LIGHT_GREEN else color.BLACK);...no value just the color
- 12:52 MTS1: an if / then statement always starts with "if"
- 12:53 DougN: there is if right before value...wrong place?
- 12:53 MTS1: use http://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/If.html or
- http://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/if.html
- 12:53 DougN: ok...thx!!!
- 12:53 MTS1: look at the syntax on those pages and decide what works best. The function seems easiest?
- 12:54 AlphaInvestor: ooh ooh ooh ... help me next -- Horseshack from Everybody Loves Cotter
- 12:54 MTS1: The reference is a great place; put the function in the reference filter on the right top of the page, or search. HowTo's are great also to get to learn the platform.
- 13:02 technicaltraderoom: MTS1 here is the context, I'm grabbing the zigzagsign bubble amounts when the reversal amount is set to 0.1 so I can get the average movement in both the positive and negative direction of an equity.
- For example, over 840 1m candles (two days) there were 20 zigzag bubbles generated by the study, so there is technically 820 0's and 20 numbers that give you the movement amount. I'm looking to remove all those 0s in the computation of the average, I just want it to compute the average over those 20 zigzag bubbles.
- 13:03 technicaltraderoom: I've separated positive movements from negative movements, but as stated above, everything but the bubble amounts generated by the zigzagsign study are 0s so it kills the average. I'm looking to remove those 0s.
- 13:03 MTS1: Doug; FYI you can still have if statement in the AssignBackgroundColor Variable; like my AddLabel Sample above; like AssignBackgroundColor(if IsNaN("value" = PPS().buysignal) then Color.GREEN else Color.RED);
- 13:08 AlphaInvestor: Sounds like a job for FOLD not Average()
- 13:09 AlphaInvestor: sum up the non-zero numbers in a FOLD statement
- count the non-zero numbers in a FOLD statement
- divide to get the average
- 13:10 technicaltraderoom: I'll give it a shot, thanks Alpha
- 13:12 technicaltraderoom: That should work as a quick patch, since I know the value of n here (how many values above 0), but sounds like it will not be an option when I don't know the value of n
- 13:13 AlphaInvestor: No, that is why you Count the number of non-zeros in a separate FOLD
- 13:13 AlphaInvestor: Well, I need to get home to gorge myself on corned beef and cabbage - Later Traders
- 13:13 technicaltraderoom: Smart, not sure why I didn't see that as an option
- 13:13 technicaltraderoom: Thanks again
- 13:22 FrankB3: Anyone know if this is a "small trader sentiment " indicator or script... would like a RSI ???/
- 13:27 MTS1: Frank; what is "this" ?
- 13:27 AlphaInvestor: Would TD Ameritrade's $IMX work?
- 13:27 AlphaInvestor: If not, AAII Investor Sentiment Survey would be my choice
- 13:29 UpTheCreek: Doug, if you return, there is a trick to PPS buy and sell signals, they aren't boolean, they are numbers.
- 13:30 AlphaInvestor: but 1 and 0 equate to booleans anyways ...
- 13:30 UpTheCreek: but it's worse than that
- 13:31 AlphaInvestor: oh, I never plotted them
- 13:31 UpTheCreek: if I remember right it a number or NaN
- 13:32 FrankB3: thanks AI::: will check it out.... seems like when a the small traders(under 10K) are in total agreement on down turns >>> signals a change to the upside
- 13:34 FrankB3: 16:27 MTS1: a non-price view of market reaction
- 13:35 UpTheCreek: last time I checked, nobody asked me how big my account was the last time I placed a trade
- 13:36 MTS1: Frank; still not sure what indicator or script you were looking at. But same applies to Speculators in COT, newsletter publisher survey, etc. You're looking for contrarian signals?
- 13:36 AlphaInvestor: mine keeps changing in value ... one day I am a big trader, next week I am a pipsqueak
- 13:36 FrankB3: Yep,,, there is some private research being done... I don't know how they obtain their info
- 13:37 UpTheCreek: you could use COT data as well for small specs...just not on ToS :(
- 13:37 FrankB3: Oh, yea:: then I.m a pipsweak of a pepsqueak
- 13:39 FrankB3: I think in the COT data: you can find proffesionl traders data, each week
- 13:39 MTS1: Google it Frank; COT is public, and there are free sites to chart it. Google fin newsletter sentiment for hulbert, etc.
- 13:39 jmachado: Alpha, how exactly would you go about adding up those non-zero numbers using a fold statement?
- 13:40 FrankB3: thanks guys ,,, later
- 13:41 AlphaInvestor: JM - I am not a good FOLDer
- 13:41 jmachado: Neither am I sadly haha
- 13:43 AlphaInvestor: somethinng like this
- def SumUp = if MyVariable > 0
- then SumUp + MyVariable
- else SumUp[1] ;
- 13:43 UpTheCreek: then run a seperate counter variable for each non zero number you have. It may work for what you are doing, or not...
- 13:43 AlphaInvestor: def CountUp = if MyVariable > 0
- then SumUp + 1
- else SumUp[1] ;
- 13:44 AlphaInvestor: oops
- def CountUp = if MyVariable > 0
- then CountUp + 1
- else CountUp[1] ;
- 13:45 jmachado: I'll plug it in and give it a shot, thanks
- 13:46 AlphaInvestor: Later Traders
- 15:25 jmachado: For Alpha or anyone who can give further insight, I attempted to do what Alpha suggested and came up with the following
- 15:25 jmachado: def price = close;
- def reversalAmount = 0.1;
- def "ZZ$" = reference ZigZagHighLow(price, price, 0, reversalAmount, 1, 0);
- def zzSave = if !IsNaN("ZZ$") then price else GetValue(zzSave, 1);
- def chg = price - GetValue(zzSave, 1);
- def barNumber = BarNumber();
- def Up = if !IsNaN("ZZ$") and chg > 0 then chg else no;
- def CountUpN = if Up > 0
- then CountUpN + 1
- else CountUpN[1] ;
- def CountUpTotal = if Up > 0
- then CountUpTotal + Up
- else CountUpTotal[1] ;
- plot UpAverage = CountUpTotal/CountUpN;
- def Down = if !IsNaN("ZZ$") and chg < 0 then chg else no;
- def CountDownN = if Down < 0
- then CountDownN + 1
- else CountDownN[1] ;
- def CountDownTotal = if Down < 0
- then CountDownTotal + Down
- else CountDownTotal[1] ;
- plot DownAverage = CountDownTotal/CountDownN;
- 15:25 jmachado: Unfortunately nothing is coming up, so I'm going to keep working on it, but any insight would be much appreciated. Thanks.
- 15:46 Jake-Elwood: looks to me that you are feeding the zzHL study some garbage inputs which result in no zigzag from being drawn. Review the details about the study and see what it really needs.
- Plot out your intermediate values so you can see more of what is going on....like this:
- plot zzsave_ = zzSave;
- zzSave_.setPaintingStrategy(paintingStrategy.VALUES_BELOW);
- 15:46 Jake-Elwood: http://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/ZigZagHighLow.html
- 15:53 jmachado: Not sure what you're saying Jake, as the Up and Down items correctly isolate and display the zigzagsign bubbles I'm referring to.
- 15:58 Jake-Elwood: I see no bubbles in your code
- 15:58 jmachado: Please read up to the prior conversation for context
- 16:00 jmachado: I basically copy-pasted the code for ZigZagSign, and the Up/Down in the code above is what the bubbles in the ZigZagSign code uses to get that data.
- 16:02 jmachado: The issue here is isolating that data from all the zeros in-between to create an average. My end goal is to get the average of all of positive movement that you see in the bubbles of the ZigZagSign study. The same for the negative movement as well.
- 16:04 Jake-Elwood: well, I don't know what's your code and what's ToS code in that script you posted a half hour ago, all I'm saying is that it starts out not working and stays that way. If you think otherwise, that's fine, maybe I'm missing something significant.
- 16:06 jmachado: Thanks for attempting to help though
- 16:07 Jake-Elwood: np
- 16:13 MTS1: JM; so instead of using FOLD you are now just attempting to retain the prior value if ZZ$ does not return a value?
- 16:17 jmachado: MTS1, Yes, I'm going off of what Alpha suggested above in his example code.
- 16:17 jmachado: Never used fold before, not sure how to tackle it
- 16:19 jmachado: If you'd be willing to share any insight on properly using fold it would be greatly appreciated
- 16:19 JFoy: Newbie here. How can I add ATR to a Scan?
- 16:21 MTS1: JM; there will be more experts in on Monday; I'm not. But check your values; I tried plotting the first defs and don't think that's what you want to be using. Alpha's example was skipping the 0's, not using the prior value on each bar:
- 16:21 MTS1: Plot these as triangles or somethign in different colors:
- 16:21 MTS1: plot ZZ = reference ZigZagHighLow(close, close, 0, .1, 1, 0);
- def zzSave = if !IsNaN(ZZ) then close else GetValue(zzSave, 1);
- plot zz_ = zzsave;
- plot chg = close +25- GetValue(zzSave, 1);
- addlabel(1,"chg"+chg);
- 16:25 MTS1: I guess I'm confused where zzSave comes in
- 16:25 jmachado: Wish I could share screenshots here
- 16:26 MTS1: (or chg). I thought you just wanted to average the last ZZ$ values?
- 16:27 MTS1: You can share screenshots; just make sure they are small enough. Also after you paste them in chat box make sure to right-click and zoom to 10% before posting here.
- 16:27 MTS1: May need to reduce size of screenshot before you can paste in chatbox though if you get bad size error.
- 16:29 jmachado: 
- 16:30 jmachado: On the price chart is the ZigZagSign study, with the bubbles on showing the movement from each reversal identified by the study
- 16:31 jmachado: On the bottom is the Up and Down from my code, but replacing the def with plot, to show that it is isolating and plotting the same numbers from the ZigZagSign study
- 16:31 jmachado: In short, I want to take all the green bubbles (positive movements) from the ZigZagSign study and get an average of them. Same with the red bubbles.
- 16:33 jmachado: My plot basically goes: 0, 0, 0, 0, 0, 0.355 and if I try to get an average from that it includes all of the 0s in its computation
- 16:34 jmachado: I just want to create a study that adds the "0.355, 0.2273, 0.2369, 0.3251, etc." from the ZigZagSign study above and creates an average of them.
- 16:35 jmachado: Hopefully that clears up what I'm looking for
- 16:35 Deadboydeath0: hey guys i new to tos platform and i got a question: why did my trades get rejected with bp= -1 share illegal.
- 16:36 Deadboydeath0: REJECTED: You will open a prohibited position with BP: illegal -1 share
- 16:36 Deadboydeath0: i have enough capital but cant
- 16:36 Deadboydeath0: is it because the market is not open now?
- 16:40 jmachado: Deadboy, use the live support, they will be able to look at your account and give you the exact answer why
- 16:40 jmachado: Could be a permissions issue, could be a few things
- 16:40 jmachado: This is a chat for talking about thinkscript
- 16:54 amalia: ^What he said.
- 16:54 amalia: Most of the time, that is.
- 17:05 Gadgets: hello
- 17:05 amalia: http://tos.mx/h8jhb2
- Weekly targets for swing trading. New idea of the week
- 17:06 amalia: I find it works best on indices.
- 17:11 markps: Amalia, what general time frame do you use this with?
- 17:11 markps: .
- 17:13 markps: Obviously, it is weekly, just wondering the method to the madness.
- 17:16 jmachado: MTS1 any futher thoughts or inputs to what I shared above?
- 17:21 MTS1: JM; is that for the script you posted above? I
- 17:21 MTS1: I'm not able to replicate
- 17:24 MTS1: Checked your notes again above; seems you're missing the sum of the ZZ values. Alpha's example was to sum the instances you want to average, and count how often they occured, then divide them. That's not what I see in your script.
- 17:26 amalia: Swings for me are usually 10dte or less. These are just levels to target or start position from
- 17:27 MTS1: 15:43 AlphaInvestor: somethinng like this
- def SumUp = if ZZ$ > 0
- then SumUp + ZZ$
- else SumUp[1] ;
- 15:44 AlphaInvestor:
- def CountUp = if ZZ$ > 0
- then CountUp + 1
- else CountUp[1] ;
- 17:27 MTS1: Assuming ZZ$ is the value you;ve plotted. Then divide SumUp by CountUp
- 17:34 jmachado: def price = close;
- def reversalAmount = 0.1;
- def "ZZ$" = reference ZigZagHighLow(price, price, 0, reversalAmount, 1, 0);
- def zzSave = if !IsNaN("ZZ$") then price else GetValue(zzSave, 1);
- def chg = price - GetValue(zzSave, 1);
- plot Up = if !IsNaN("ZZ$") and chg > 0 then chg else no;
- plot Down = if !IsNaN("ZZ$") and chg < 0 then chg else no;
- 17:34 jmachado: So if you post this above it doesn't give you what I have in my screenshot?
- 17:34 jmachado: Because it should
- 17:40 jmachado: Also, the example you're posting returns nothing as well
- 17:41 jmachado: I appreciate the input but I fear we're not on the same page, perhaps I'm just not explaining what I'm looking to accomplish well enough, thanks for the help though.
- 17:42 amalia: yw
- 17:50 amalia: NOOO tculs
- 17:50 amalia: I see you typing =(
- 17:51 admin_tculs: thinKScript Lounge chatroom will be closing soon Please finish all conversations by 8pm ct Have a nice evening
- 17:51 amalia: gn tculs and room
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement