Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 15:26 AutoElliott: anybody now how i can get my indicator on tos
- 15:26 AutoElliott: know
- 15:29 harndog2: yes, and we're independent traders who don't read minds.
- 15:30 harndog2: So, you to privide context
- 15:30 harndog2: need to
- 15:30 harndog2: provide
- 15:30 harndog2: Kinda like school...
- 15:31 AutoElliott: anyone from TOS here
- 15:31 JPera: HI AI
- 15:31 harndog2: Yes, admins on right
- 15:32 harndog2: The rest of us are independent and TOS does not do auto trading, if that's your question
- 15:34 AutoElliott: i would like to get my EW inicator on the TOS platform for all to use but i do not want to expose the code
- 15:34 harndog2: Contact John Hart via Twitter
- 15:34 harndog2: Make a proposal
- 15:35 AutoElliott: cool thanks
- 15:35 harndog2: Or, contract support at Thinkorswim.com
- 15:36 harndog2: My experience is TOS does not do "locked codes, unless a grandfathered relationship
- 15:36 harndog2: However, you might be special, so go for it.
- 15:38 AutoElliott: no john hart twitter
- 15:38 harndog2: jhart@tda
- 15:39 harndog2: later traders
- 15:40 JPera: BYE
- 15:52 brian_s: K-9, Your request wasn't clear, 3 lengths, 3 agg's , 3 symbols , ???
- then what, all displayed as one, or seperate lines, or ??
- What's adxSPYrange ?
- If you were more clear then maybe someone will have the time.
- 15:55 brian_s: BbL
- 16:04 K-9: brian_s: 3 seperate level lines,I call it each range, ,for each SPY,IWM,QQQ. to display when def Exp = ADX>=20 and ADX25 ;as red
- and def NExp = ADX20; as green, Hope it makes it clear...
- 16:38 les1: How to plot uparrow when ever stock falls in squeeze (TTM_Squeeze indicator) i.e on red dot red arrow and on green dot green arrow in top chart not in bottom one
- 16:42 Melissaq: Hi traders,
- 16:42 Melissaq: Good Evening
- 16:43 Melissaq: does anyone has autoplot of the fibinacci extention scripts.
- 16:43 Mobius: les1 - this study plots a squeeze on the upper chart as a channel so that you can plainly see when price is breaking out of a squeeze. Much better than that TTM_CACA
- # Volatility Compression Pivots (Squeeze Pivots)
- # Mobius
- # V01.01.2015
- #hint: Squeeze Pivots \n A different way to look at the traditional Squeeze. Plots the mean, high and low of the squeeze zone, making it easier to see which way price expansion is likely to go.
- # User Inputs
- input n = 20; #hint n: Length for calculations.
- input MeanValue = HL2; #hint MeanValue: Point of origen.
- input SdMulti = 2.0; #hint SdMulti: Multiplier for St Dev.
- input AtrMulti = 1.5; #hint AtrMulti: Multipliter for ATR.
- input DisplayPoints = yes;#hint DisplayPoints: No Points.
- input OnExpansion = yes; #hint OnExpansion: Line extensions.
- # Variables
- def o = open;
- def h = high;
- def l = low;
- def c = close;
- def bar = BarNumber();
- def Avg = Average(c, n);
- def SD = StDev(c, n);
- def ATR = Average(TrueRange(h, c, l), n);
- def upperSD = Avg + (SdMulti * SD);
- def lowerSD = Avg + (-SdMulti * SD);
- def upperATR = Avg + (AtrMulti * ATR);
- def Squeeze1 = if upperSD crosses below UpperATR
- then MeanValue
- else Squeeze1[1];
- def Squeeze = upperSD < upperATR;
- def SqueezeBars = if upperSD < upperATR
- then bar
- else Double.NaN;
- def StartBar = if upperSD crosses below upperATR
- then bar
- else StartBar[1];
- def LastSqBar = if upperSD crosses above upperATR
- then bar
- else LastSqBar[1];
- def PP = if upperSD crosses below upperATR
- then MeanValue
- else PP[1];
- def Mean_Limit = if bar != StartBar
- then bar - StartBar
- else if bar == StartBar
- then Double.NaN
- else Mean_Limit[1];
- def SqHigh = if upperSD crosses below upperATR
- then h
- else if bar > StartBar and Squeeze and
- h > SqHigh[1]
- then h
- else SqHigh[1];
- def SqHighBar = if Squeeze and
- h == SqHigh
- then bar
- else SqHighBar[1];
- def SqHigh_Limit = if bar == StartBar
- then Double.NaN
- else if bar > StartBar
- then bar - SqHighBar
- else SqHigh_Limit[1];
- def SqLow = if upperSD crosses below upperATR
- then l
- else if Squeeze and
- l < SqLow[1]
- then l
- else SqLow[1];
- def SqLowBar = if Squeeze and
- l == SqLow
- then bar
- else SqLowBar[1];
- def SqLow_Limit = if bar == StartBar
- then Double.NaN
- else if bar > StartBar
- then bar - SqLowBar
- else SqLow_Limit[1];
- def PercentSD = Round((c - lowerSD) / (upperSD - lowerSD), 2);
- def PSDhigh = highest(percentSD, n);
- def PSDlow = lowest(percentSD, n);
- # Internal Script Reference
- script LinePlot {
- input LineLimit = 0;
- input OnExpansion = yes;
- input data = close;
- input bar = 0;
- def ThisBar = HighestAll(bar);
- def cLine = if bar == ThisBar
- then data
- else Double.NaN;
- def cond1 = CompoundValue(1, if IsNaN(data)
- then cond1[1]
- else data, data);
- plot P = if ThisBar - LineLimit <= bar
- then HighestAll(cLine)
- else Double.NaN;
- plot ExpLine = if OnExpansion and
- IsNaN(data[-1])
- then cond1
- else Double.NaN;
- }
- # Plots
- plot SD_Pivot = LinePlot(data = PP, LineLimit = Mean_Limit, OnExpansion = OnExpansion, bar = StartBar).P;
- plot SD_Pivot_X = LinePlot(data = PP, LineLimit = StartBar).ExpLine;
- SD_Pivot.SetDefaultColor(Color.CYAN);
- SD_Pivot_X.SetDefaultColor(Color.CYAN);
- plot SD_R1 = LinePlot(data = SqHigh, LineLimit = SqHigh_Limit, OnExpansion = OnExpansion, bar = SqHighBar).P;
- plot SD_R1_X = LinePlot(data = SqHigh, LineLimit = SqHigh_Limit).ExpLine;
- SD_R1.SetDefaultColor(Color.Light_GREEN);
- SD_R1_X.SetDefaultColor(Color.Light_GREEN);
- plot SD_S1 = LinePlot(data = SqLow, LineLimit = SqLow_Limit, OnExpansion = OnExpansion, bar = SqLowBar).P;
- plot SD_S1_X = LinePlot(data = SqLow, LineLimit = SqLow_Limit).ExpLine;
- SD_S1.SetDefaultColor(Color.Light_RED);
- SD_S1_X.SetDefaultColor(Color.Light_RED);
- plot SqueezePlot = if Squeeze
- then Squeeze1 #l - (2 * TickSize())
- else Double.NaN;
- SqueezePlot.SetHiding(!DisplayPoints);
- SqueezePlot.SetPaintingStrategy(PaintingStrategy.POINTS);
- SqueezePlot.SetLineWeight(1);
- SqueezePlot.SetDefaultColor(Color.Yellow);
- addCloud(SD_pivot, SD_R1, CreateColor(50,150,75), CreateColor(50,150,70));
- addCloud(SD_S1, SD_pivot, CreateColor(175,0,50), CreateColor(175,0,50));
- addCloud(SD_pivot_X, SD_R1_X, CreateColor(50,150,75), CreateColor(50,150,70));
- addCloud(SD_S1_X, SD_pivot_X, CreateColor(175,0,50), CreateColor(175,0,50));
- def SDCD = if AbsValue(upperSD - upperATR) > AbsValue(upperSD[1] - upperATR[1])
- then 1
- else 0;
- # Audible Alerts
- Alert(upperSD crosses above upperATR, "Squeeze Exit", Alert.BAR, Sound.Bell);
- Alert(c crosses above upperSD, "Violation of Upper Band", Alert.BAR, Sound.Bell);
- AddLabel(Squeeze, if close > SD_Pivot
- then "Squeeze Expanding Up"
- else if close < SD_Pivot
- then "Squeeze Expanding Down"
- else "In Squeeze",
- if close > SD_Pivot
- then Color.Green
- else if close < SD_Pivot
- then Color.Red
- else Color.Yellow);
- # End Code Volatility Compression Pivots
- 16:43 Melissaq: es anyone has autoplot of the fibonacci extention scripts.
- 16:48 JPera: mo
- 16:48 JPera: lol
- 16:48 JPera: ttmcaca
- 16:48 JPera: mo
- 16:48 JPera: i have a request
- 16:48 JPera: that i was working on yesterday
- 16:48 JPera: but got too sleepy and tired
- 16:49 les1: Thanks Mobius, I tried below it is plotting arrow for all candles# Squeeze watchlist column
- def sqz = !TTM_Squeeze().SqueezeAlert;
- def count = if sqz and !sqz[1] then 1 else count[1]+1;
- def fired = if !sqz and sqz[1] then 1 else 0;
- addLabel(yes, if sqz then "Squeeze:" + count else if fired then "Fired" else "-", if sqz then color.red else
- color.green);
- plot UP = sqz > 0;
- UP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
- 16:49 les1: I'll try your study
- 16:50 strategyman: I have a questoin
- 16:51 strategyman: Hello, I was wondering. I have two studies. One line that shows the 50 day moving average and one that shows that 10 day moving average. How do I set an alert for when the 10 day moving avergage crosses above the 50 day moving avergage? and an alert for when it crosse below the 50 day ine
- 16:52 Melissaq: Hello Mobius,
- 16:52 strategyman: anyone know?
- 16:52 razorbackfan: Does anybody have a label created for an RSI overbought 70 oversold 30 created?
- 16:53 Melissaq: Do you have Fibonacci extention autoplot scripts.Thanks
- 16:53 Mobius: Melissa.. there are quite a few fibonacci retracement studies floating around but I've not seen a Fibonacci Extension study as the TOS drawing tool draws one in TOS. You can add extension coefficients above 100 and below 0 on the Retracement studies.
- 16:53 les1: @Melissaq, here is the auto fib code working only on daily. select 1day 15min ...............modify and let me know if you can fix for multi days http://tos.mx/QV13w2##....................I got this from here only
- 16:54 Melissaq: Les!...The URL is broken, ls send again
- 16:55 strategyman: ?
- 16:55 Melissaq: OK. Thanks Mobius . Will try it out
- 16:55 les1: the one which i gave is for fib retracement not for extensions
- 16:55 AlphaInvestor: copy the 6 characters after the / and put into the Setup - Open Shared Item box
- 16:55 Mobius: strategy... Without seeing your plot expressions I can give you a general idea
- Alert(condition, "Text", Alert.Type, Alert.Sound);
- 16:57 strategyman: yes but when i put alert "study" i can choose condition of true or false
- 16:57 strategyman: but first id need to tell the platform what is true adn what is false
- 16:57 strategyman: any idea of how to do it
- 16:57 strategyman: basically i have two lines one 10 day and one 50 day averagle lines
- 16:57 strategyman: thats all thats on my chart along with the price movements
- 16:58 Mobius: razor...
- Alert(RSI() crosses above OverSold, "RSI crosses OverSold", Alert.Bar, Sound.Bell);
- Alert(RSI() crosses below OverBought, "RSI crosses OverBought", Alert.Bar, Sound.Ring);
- 16:58 strategyman: where do i write that in?
- 16:59 les1: @Melissaq remove ## at the end
- 16:59 AlphaInvestor: As I said in the trader lounge, if you really have 2 stuies they need to be combined into one
- 16:59 strategyman: no one has told me how to combine them
- 16:59 AlphaInvestor: or just start with the Moving Average Two Line study
- 16:59 strategyman: sorry I am new to this platform
- 16:59 JPera: AI
- 16:59 JPera: i need help
- 16:59 trader990: Hi guys, is it possible to get alerted when the value of a plot is returning as "N/A",please advise thanks.
- 17:00 AlphaInvestor: Strategy - copy/paste - then clean up duplicates
- 17:01 AlphaInvestor: Strategy - I would look at the MovingAverageTwoLine study to see if it would work as a starting point.
- 17:03 Mobius: trader - if isNaN(condition) then 1 else 0;
- 17:06 trader990: Thanks Mobius, here is what i am trying to accomplish ,i got this study in the room a while back and i added the bid and ask values to it to be displayed as a chart bubble
- 17:06 trader990: def lastbar = HighestAll(if !isNaN(close) and IsNaN(close[-1]) then BarNumber() else Double.NaN);
- #AddChartBubble(barnumber() == lastbar, high, "O: " + open + "\nHi: " + high + "\nLo: " + low + "\nClose: " + close, Color.cyan, yes);
- def A = close(priceType = "Ask");
- def B = close(priceType = "Bid");
- 17:06 trader990: AddChartBubble(barnumber() == lastbar, high, "O: " + open + "\nHi: " + high + "\nLo: " + low + "\nClose: " + close +"\nBid:" +B + "\nAsk:"+ A, Color.cyan, yes);
- 17:07 trader990: but sometimes in fast markets the bid and ask values return as N/A
- 17:08 thegoodman19: how do I get access to the TD-A API? there is no other way than the email they provide? what is the criteria for access to the API? not for me just to mess with it seems?
- 17:08 trader990: I want to be alerted when this N/A happens
- 17:08 Mobius: trader your bubble placement can be one bar into the future or many the code is ambiguous
- 17:09 Mobius: if the bubble is in the expansion area then there may not be a value for it to find
- 17:09 trader990: Mobius it returns the OHLC bid and ask of the current bar
- 17:10 trader990: in fast markets or the beginning of each bar it could be both the N/A value appears
- 17:11 Mobius: trader - last bar with a OHLC or ask or bid is
- last_bar = if isNaN(close) then barNumber() else last_bar[1];
- 17:11 Mobius: sorry missed an indexer
- last_bar = if isNaN(close[-1]) then barNumber() else last_bar[1];
- 17:12 trader990: so if i want to get alerted when N/A occurs what would be the syntax for the alert
- 17:12 Mobius: I told you that already
- 17:12 trader990: ok i will try Mobius
- 17:13 trader990: thanks so much
- 17:13 Mobius: I also told you your lastbar isn't producing what you think it is
- 17:15 trader990: but the OHLC values is corrrect though
- 17:19 Mobius: Where did you want your bubble located, on top of the last bar?
- 17:20 trader990: yes it is on the last bar
- 17:20 razorbackfan: Thank you, Mobius
- 17:21 Mobius: OK never mind then my mistake
- 17:21 trader990: so when ASK is N/A or the bid is N/A i just want to get alerted
- 17:22 trader990: i think your code is working Mobius , i just put A instead of close to identify the ask
- 17:23 trader990: here is what i added
- Alert(lastbar == if isNaN(A) then barNumber() else lastbar[1]
- , "CLOSE=ASK ALERT!", Alert.TICK, Sound.CHimes);
- 17:25 Mobius: trader - as an FYI these three methods are all equivalent
- def lastbar = HighestAll(if !isNaN(close) and IsNaN(close[-1]) then BarNumber() else Double.NaN);
- def Last_Bar = if isNaN(close[-1]) then barNumber() else Last_Bar[1];
- def bar = barNumber();
- AddLabel(1, "lastbar = " + lastbar +
- " Last_Bar = " + Last_Bar +
- " Current Bar Number = " + bar, color.white);
- 17:25 AlphaInvestor: trader - the first position in Alert() is supposed to be a boolean - you have it coming out as a number (barnumbe, or lastbar)
- 17:26 Mobius: Alpha.. it will always be true sp it's a go around your elbow to get to your butt way of writting yes or 1
- 17:26 AlphaInvestor: How is Dilbert today, got any good Options stuff going on
- 17:26 Dilbert: Besides the VIX products what other symbols can be traded to benifit from contango?
- 17:26 Mobius: oil
- 17:27 AlphaInvestor: dilbert - any /Future could go into backwardation
- 17:27 JPera: which study are you guys talking about?
- 17:27 Dilbert: Dilbert is good, very good.
- 17:27 AlphaInvestor: /CL /NG are common tho
- 17:27 Mobius: backwardation and contangio I love it when there's dirty options talk around here
- 17:27 trader990: Thanks Mobius ,Alpha ,always learning from you guys ,trying to get my head wrapped around the code logic
- 17:28 noitadrawkcaB: Mobius - me too
- 17:28 Mobius: yw trader
- 17:29 Dilbert: USO suffers from contango, but the effect is not as strong as like for VXX or XIV.
- 17:31 Dilbert: What kind of study could be coded to get signals between the relationship between /VX and VXX or XIV?
- 17:36 twoshoes:
- 17:40 mtroche: Good afteernoon, everyone! I need your help. I am trying to test my startegy and added this line to my code "AddOrder(OrderType.BUY_TO_OPEN, BuyCondition, close, 5000, Color.ORANGE, 0);", but it is not working. By the way, I already defined "BuyCondition". What I am doing wrong?
- 17:45 mtroche: Am sorry, guys... This is he right code I have issues: AddOrder(OrderType.BUY_TO_OPEN, BuyCondition, close, 5000, Color.ORANGE, 0, "Bought @ " + close); For some reason itis is not working and AddOrder is in red. does anyone have some time to help me out?
- 17:53 Mobius: mtroche = your conditions need work
- AddOrder(inttype.IDataHolder, condition, price, tradeSize, CustomColor.tickColor,CustomColor.arrowColor, String name);
- 17:54 Mobius: your arrow color can not be 0
- 17:55 mtroche: Mobius - Thank youu, Mobius. What can I do if I do not want an arrow to show?
- 17:55 Mobius: color it the background color
- 17:56 AlphaInvestor: there should be two colors in there too
- AddOrder(OrderType.BUY_TO_OPEN, BuyCondition, close, 5000,color.orange,color.orange, "Bought @ " + close);
- 17:56 AlphaInvestor: oh, that is what Mobius said first - my bad
- 17:57 mtroche: AlphaInvestor and Mobius -- Thank both! What can i do if I do not want the arrow to show?
- 17:58 les1: Hi, I'm looking for the below study, if anyone has the code already can you please share....Expected up or down move of a stock. Standard deviation 1 and 2 as expected up move, -1 and -2 as downward expected . plot two up and two down price lines in the right
- 17:58 Mobius: mtroche - I Told you already. You can color it the background color. TOS will plot it regardless of what you want so all you can do is hide it
- 18:02 strategyman: question does this code.....SimpleMovingAvg("length" = 10) crosses above SimpleMovingAvg("length" = 50) and SimpleMovingAvg("length" = 10) crosses below SimpleMovingAvg("length" = 50) have two alerts at once
- 18:02 Mobius: les.. There are expected move studies on MyTrade. Bollinger Bands can be used for Standard Deviation Bands as can Standard Deviation Bands and TOS native VWAP and Linear regression with standard deviation bands
- 18:02 strategyman: ?
- 18:02 mtroche: Mobius - I'm sorry Mobius. I just saw you already answered. Thank you so much, Mobius!
- 18:05 Mobius: strategyman - as you've written that line of code it is looking for the opposite condition in the same bar
- 18:06 strategyman: so it should be and SimpleMovingAvg("length" = 10) crosses below SimpleMovingAvg("length" = 50)
- 18:06 Mobius: that would be a single condition and a good signal for an alert
- 18:07 Mobius: A simpler way to write that would be
- Average(close, 10) crosses below Average(close, 50);
- 18:07 strategyman: okay and i set "1m" and in the condition part i can pick "close" does that mean it will only tell me if it does it at the close or will it check every minute during the day?
- 18:07 strategyman: whats "close" mean?
- 18:08 Mobius: in TOS close is the current floating price
- close[1] is the close of the previous bar
- 18:10 strategyman: ok so ig at 2:50 its below the 50 day then at 2:52 its above it will alert me?
- 18:11 Mobius: if it crosses below it will alert
- 18:12 Mobius: your asking if it crosses above will it alert
- 18:12 Mobius: if the price is closer to your head and crosses closer to your toes it will alert
- 18:13 strategyman: ok and whats this "1m" thing I clicked on?
- 18:13 Mobius: that is 1 minute aggregation. Like a 1 minute chart. 1 minute bars
- 18:14 strategyman: should i have that on?
- 18:14 Mobius: these are all questions you can learn from the manual
- http://tlc.thinkorswim.com/center/charting/thinkscript.html
- 18:15 Mobius: I charge 300.00 per hour and your asking me two cent questions. Read the manual and come back
- 18:16 mtroche: Mobius - Please, could you heck my code and let me know what else I am doing wrong? AddOrder(OrderType.BUY_TO_OPEN, BuyCondition, close[0], 5000, Color.ORANGE, Color.BLACK, "Bought @ " + close[0]); When I add it to the end of my code no signals are shown including the ones I already have in my code, and i have no idea what else I am missing.
- 18:17 Mobius: mtroche - the line is correct so check the BuyCondition
- 18:18 strategyman: okay thank you
- 18:18 mtroche: Mobius - Here's my buy conditionn in my code:
- def BuyCondition2 = AC crosses above 0;
- #def BuyCondition3 = DiffMACD[1] >= 0;
- #def BuyCondition4 = DiffMACD <= 0;
- #def BuyCondition4 = DiffMACD crosses above 0 within 3 bars;
- def BuyCondition4 = DiffMACD crosses above 0;
- #def BuyCondition = BuyCondition1 + BuyCondition2 + BuyCondition3 + BuyCondition4;
- def BuyCondition = (BuyCondition2 and BuyCondition4);
- 18:20 Mobius: Condition 2 and 4 are excluding one another
- 18:21 Mobius: select one or the other. Crossing is a Boolean Conditon while greater than or equal is a State condition
- 18:22 Mobius: your askig for 2 different algorithms to align to the same bar. This would be more likely
- Condition 2 = AO >= 0
- Condition 4 = DiffMACD crosses above 0
- 18:23 Mobius: or visa versa
- 18:24 mtroche: Mobius - :-( So... Even though I have no issues with the rest of my coe using BuyCondition, I cannot use it with AddOrder...? I need BuyCondition to happen to buy; so, is there any way around it?
- 18:25 Mobius: your not making any sense
- 18:25 Mobius: You have 2 Boolean conditions trying to signal a buy.. How likely is that to happen on the same bar??
- 18:26 Mobius: Either make if fuzzy by adding within bar condition or make one of the variables a State conditon and the other Boolean
- 18:28 Mobius: Your trying to run before you can walk too.. You should read the manual and understand the difference in condational variables before trying to write a strategy.
- 18:33 mtroche: Obviously, I am a very biginning with ThinkScript and coding... Also, BuyCondition works with the rest of my code, and I am reading the manual, but I am not a fast learner and I need a lot of practive to learn; so, that's the reason I am asking to you guys that have a lot of experience and time working with ThinkScript.
- How can i change them to be the same condition?
- 18:36 Mobius: I told you already above.
- Change your lines of code so that one is Boolean and one is a State
- def BuyCondition2 = AC >= 0;
- def BuyCondition4 = DiffMACD crosses above 0;
- def BuyCondition = (BuyCondition2 and BuyCondition4);
- 18:38 Mobius: This is the difference
- def BuyCondition2 = AC >= 0; # State Condition
- def BuyCondition4 = DiffMACD crosses above 0; # Boolean
- def BuyCondition = (BuyCondition2 and BuyCondition4);
- 18:42 TradeKind: quikc last question and i am very grateful ...If I Created an alert and set up my email and phone number, will i get email and text alerts even if think or swing is not open?
- 18:43 Mobius: Trade.. Yes. Once a MarketWatch Alert is set the platform can be closed and you will still get the alert since it is set Server side
- 18:47 mtroche: Mobius - Thank you, Mabius. I think I got it. I think it iwll work out if I use:
- def BuyCondition2 = AC crosses above 0:
- def BuyCondition4 = DiffMACD crosses above 0:
- Thank you fro your time, Mobius.
- 18:47 Mobius: Nope you don't have it
- 18:54 mtroche: Mobius - Yeap, I think got it after reading your answer twice... Thank you for your patience.
- 18:58 mtroche: Mobius - No wait.... I need those values to not be just over 0, but to be the values when the histograms are crossing over 0; so, >=0 is nt going to work for me. Any other idea?
- 19:18 KRFL: van anyone tell me what is a modadx?
- 19:20 mtroche: Mobius - I just changed them but the situation persists. Here's my code,, now:
- 19:23 mtroche: Mobius - I just changed them but the situation persists. Here's my code, now:
- def BuyCondition2 = AC crosses above 0;
- def BuyCondition4 = if DiffMACD[-1]<=0 and DiffMACD[0]>0 then 1 else 0;
- 19:25 KRFL: does it exist in TOS....?
- 19:26 Mobius: KRFL that could be anything. There is no function like that in TOS so it's most likely a variable name
- 19:27 Mobius: mt... You cna use a within range to allow more flexability
- Example:
- def BuyCondition2 = AC crosses above 0;
- def BuyCondition4 = DiffMACD crosses above 0 within 3 bars;
- 19:27 KRFL: OK THANKS
- 19:27 Mobius: can
- 19:41 les1: @Mobius, thanks Mobius, I'll look bollingerband and vwap studies
- 19:51 mtroche: Mobius - I have tried everything but every time I add AddOrder command all my signs are not shwon any more and the AddOrder does not show either. Just to make it clear... from time to time bith histograms cross the zero line at the same time -- you couls take any company and play with the time and you will see. Any way, let's assume it does happen... here's my last code:
- input fastLength = 12;
- input slowLength = 26;
- input MACDLength = 9;
- input averageType = AverageType.EXPONENTIAL;
- def DiffMACD = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
- def AO = AwesomeOscillator();
- def AC = AO - Average(AO, 5);
- def BuyCondition2 = AC crosses above 0;
- def BuyConditionBuy2 = if AC[-1]<=0 and AC>0 then 1 else 0;
- def BuyCondition4 = DiffMACD crosses above 0;
- def BuyConditionBuy4 = if DiffMACD[-1]<=0 and DiffMACD>0 then 1 else 0;
- def BuyCondition = (BuyCondition2 and BuyCondition4);
- def BuyConditionBuy = BuyConditionBuy2 + BuyConditionBuy4;
- def ShortSellCondition2 = AC crosses below 0;
- def ShortSellConditionShortSell2 = if AC[-1]>=0 and AC<0 then 1 else 0;
- def ShortSellCondition4 = DiffMACD crosses below 0;
- def ShortSellConditionShortSell4 = if DiffMACD[-1]>=0 and DiffMACD<0 then 1 else 0;
- def ShortSellCondition = (ShortSellCondition2 and ShortSellCondition4);
- def ShortSellConditionShortSell = ShortSellConditionShortSell2 + ShortSellConditionShortSell4;
- plot uparrow = if BuyCondition then low else Double.NaN;
- uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
- uparrow.SetDefaultColor(Color.WHITE);
- uparrow.SetLineWeight(5);
- plot uparrowB = if BuyCondition then high else Double.NaN;
- uparrowB.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
- uparrowB.SetDefaultColor(Color.WHITE);
- uparrowB.SetLineWeight(5);
- plot downarrow = if ShortSellCondition then high else Double.NaN;
- downarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
- downarrow.SetDefaultColor(Color.WHITE);
- downarrow.SetLineWeight(5);
- plot downarrowB = if ShortSellCondition then low else Double.NaN;
- downarrowB.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
- downarrowB.SetDefaultColor(Color.WHITE);
- downarrowB.SetLineWeight(5);
- def GreenChgA = if DiffMACD > 0 then if DiffMACD[1] > DiffMACD[2] and DiffMACD < DiffMACD[1] then 1 else 0 else 0;
- plot GreenChg = if GreenChgA then high else Double.NaN ;
- GreenChg .SetPaintingStrategy(PaintingStrategy.POINTS);
- GreenChg .SetDefaultColor(Color.WHITE);
- GreenChg .SetLineWeight(1);
- plot GreenChgB = if GreenChgA then low else Double.NaN ;
- GreenChgB .SetPaintingStrategy(PaintingStrategy.POINTS);
- GreenChgB .SetDefaultColor(Color.WHITE);
- GreenChgB .SetLineWeight(1);
- def RedChgA = if DiffMACD < 0 then if DiffMACD[1] < DiffMACD[2] and DiffMACD > DiffMACD[1] then 1 else 0 else 0;
- plot RedChg = if RedChgA then high else Double.NaN ;
- RedChg .SetPaintingStrategy(PaintingStrategy.POINTS);
- RedChg .SetDefaultColor(Color.WHITE);
- RedChg .SetLineWeight(1);
- plot RedChgB = if RedChgA then low else Double.NaN ;
- RedChgB .SetPaintingStrategy(PaintingStrategy.POINTS);
- RedChgB .SetDefaultColor(Color.WHITE);
- RedChgB .SetLineWeight(1);
- AddOrder(OrderType.BUY_TO_OPEN, BuyConditionBUY==2, close[0], 5000, Color.ORANGE, Color.BLACK, "Bought @ " + close[0]);
- 19:52 mtroche: Mobius - So, what AM I doing wrong? :-(
- 19:53 mtroche: Mobius - Am sorry... What am I doing wrong? :-(
- 20:09 brian_s: mtroche, Try setting the Global Settings to allow multiple entries in the same direction to see more buys, as you need a sell AddOrder to counter the buy otherwise.
- 20:14 TradeKind: Hello, i am trying to creat a auto buy code using simple avergages. For it set an auto buy if simple 9 day avergage goes above the 50 day avergage....is this the right code:
- 20:14 TradeKind: input price1 = close;
- input lenght1 = 9;
- input displace1 = 0;
- input price2 = close;
- input length2 = 50;
- input displace2 = 0;
- def smg1 = simpleMovingAvg (price1,lenght1,displace1);
- def smg2 = simpleMovingAvg (price2,length2,displace2);
- AddOrder(OrderType.BUY_AUTO, smg1 crosses above smg2);
- 20:18 DownTheHatch: Put it on a chart and see.
- 20:18 brian_s: it won't do any real trades
- 20:19 TradeKind: what do you mean put it on a chart
- 20:19 Mobius: mtroche - first here is your code plotting in a lower graph with arrows as you first described. Is it plotting as you want?
- declare lower;
- input fastLength = 12;
- input slowLength = 26;
- input MACDLength = 9;
- input averageType = AverageType.EXPONENTIAL;
- plot DiffMACD = MACD(fastLength, slowLength, MACDLength, averageType);
- plot AC = AwesomeOscillator() - Average(AwesomeOscillator(), 5);
- plot zero = if isNaN(close) then double.nan else 0;
- plot upArrow = if DiffMACD crosses above 0 and AC crosses above 0 then 0 else double.nan;
- upArrow.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
- plot dnArrow = if DiffMACD crosses below 0 and AC crosses below 0 then 0 else double.nan;
- dnArrow.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
- 20:19 TradeKind: and can i make a strategy that automatically buys a sertian number of shares
- 20:19 brian_s: you need a crosses above line
- 20:20 TradeKind: yes but what do you mean put it in a chart
- 20:20 brian_s: thinkscript does NO real trades
- 20:21 TradeKind: okay
- 20:21 TradeKind: so just would alert me
- 20:21 TradeKind: or signal a buy and i have to accept
- 20:22 TradeKind: and thank you but how do I put it in a chart?
- 20:22 brian_s: if you can get it to work on an OCO order, but you have to reset it after every trade
- 20:23 brian_s: see what Mobius just posted above, like that
- 20:23 mtroche: brian_s - It loooks like nobody believes that both histograms cann cross at the same time at the same direction, but they do from time to time.
- Assuming that it does happen, what's wrong with my code?
- I added to my code the MACDStrat, and all my sogns disapear and the MACDStrat does not show either; even though, if I use MACDStrat with my chart without my signals it does show. What's wrong with my code?
- Please, Brian, could you take a look at my code and let me know how to fix it? My code is at 18:51 line.
- 20:26 brian_s: TradeKind, So, what does your crosses above line look like?
- http://tlc.thinkorswim.com/center/charting/thinkscript/reference/Reserved-Words/crosses.html
- 20:26 TradeKind: where is this code plotting in lower gtaph i dont understand declare lower
- 20:27 brian_s: Trade,
- http://tlc.thinkorswim.com/center/charting/thinkscript/reference/Reserved-Words/declare.html
- 20:29 TradeKind: i went to that site i just dont know where or what to click to lead me to a place to put the code
- 20:29 brian_s: mtroche, Did you find the Global settings in the Edit Studies and Strategies window?
- 20:30 brian_s: Trade,
- On the top of the chart select the beaker next to the gear.
- The "Edit Studies and Strategies" window opens.
- On the top left of the window select the Studies, or Strategies tab.
- Click on the new button, bottom left.
- The editor opens, delete the one line of existing script, and paste in your script.
- 20:31 TradeKind: i see the global settings
- 20:32 brian_s: Trade, It seems you are trying to make a strategy, so select the strategy tab, then new.
- 20:32 TradeKind: and then put the delcare lower in there
- 20:32 TradeKind: from what i saw on the site?
- 20:32 TradeKind: thanks
- 20:33 brian_s: Use your code and fit the correct Plots style from Mobius code above
- 20:34 Paris: Brian - last I looked TOS has a standard MovingAverage Strategy so perhaps he can use that
- 20:37 brian_s: FYI, yes paris, thanks, I was just typing that in, There are built in 2 movavg strats built in already. In the Edit Studies window, there is a search box top laft above list of strats, type in avg . Make sure you are under the strat tab.
- 20:39 mtroche: brian_s: I did and I changed the "Allow up to..." to "Allow up to 100 entry order(s)...", but the same situation persists. Please, could you try my code to see what's going on? I am feeling I am going in circles, here. :-(
- 20:39 brian_s: Gotta go eat, BbL
- 20:40 buzzkeeto: I would like to find the code to be able to capture a close price for x bars ago. I want to use a dynamic variable to get the number of bars as follows:
- 20:40 buzzkeeto: AddChartBubble(
- HasEarnings(),
- high,
- "The last Earnings was " +
- GetEventOffset(Events.EARNINGS, -1) +
- " bars ago");
- def E1 = getday() - geteventoffset(events.earnings,-1);
- def E1Close = close [E1];
- 20:40 buzzkeeto: I get an error for 'E1' as it wants a constant.
- 20:42 Mobius: You can't index a close with anything but a constant
- 20:43 Mobius: you will need to find the barNumber() your condition happened on then get the close at that bar.
- 20:47 mtroche: Please, could someone help me out? I have tried everything but every time I add an AddOrder command to my code all my signs are not shown any more and the AddOrder does not show either. Here's my code:
- input fastLength = 12;
- input slowLength = 26;
- input MACDLength = 9;
- input averageType = AverageType.EXPONENTIAL;
- def DiffMACD = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
- def AO = AwesomeOscillator();
- def AC = AO - Average(AO, 5);
- def BuyCondition2 = AC crosses above 0;
- def BuyConditionBuy2 = if AC[-1]=0 and AC>0 then 1 else 0;
- def BuyCondition4 = DiffMACD crosses above 0;
- def BuyConditionBuy4 = if DiffMACD[-1]=0 and DiffMACD>0 then 1 else 0;
- def BuyCondition = (BuyCondition2 and BuyCondition4);
- def BuyConditionBuy = BuyConditionBuy2 + BuyConditionBuy4;
- def ShortSellCondition2 = AC crosses below 0;
- def ShortSellConditionShortSell2 = if AC[-1]>=0 and AC0 then 1 else 0;
- def ShortSellCondition4 = DiffMACD crosses below 0;
- def ShortSellConditionShortSell4 = if DiffMACD[-1]>=0 and DiffMACD0 then 1 else 0;
- def ShortSellCondition = (ShortSellCondition2 and ShortSellCondition4);
- def ShortSellConditionShortSell = ShortSellConditionShortSell2 + ShortSellConditionShortSell4;
- plot uparrow = if BuyCondition then low else Double.NaN;
- uparrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
- uparrow.SetDefaultColor(Color.WHITE);
- uparrow.SetLineWeight(5);
- plot uparrowB = if BuyCondition then high else Double.NaN;
- uparrowB.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
- uparrowB.SetDefaultColor(Color.WHITE);
- uparrowB.SetLineWeight(5);
- plot downarrow = if ShortSellCondition then high else Double.NaN;
- downarrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
- downarrow.SetDefaultColor(Color.WHITE);
- downarrow.SetLineWeight(5);
- plot downarrowB = if ShortSellCondition then low else Double.NaN;
- downarrowB.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
- downarrowB.SetDefaultColor(Color.WHITE);
- downarrowB.SetLineWeight(5);
- def GreenChgA = if DiffMACD > 0 then if DiffMACD[1] > DiffMACD[2] and DiffMACD DiffMACD[1] then 1 else 0 else 0;
- plot GreenChg = if GreenChgA then high else Double.NaN ;
- GreenChg .SetPaintingStrategy(PaintingStrategy.POINTS);
- GreenChg .SetDefaultColor(Color.WHITE);
- GreenChg .SetLineWeight(1);
- plot GreenChgB = if GreenChgA then low else Double.NaN ;
- GreenChgB .SetPaintingStrategy(PaintingStrategy.POINTS);
- GreenChgB .SetDefaultColor(Color.WHITE);
- GreenChgB .SetLineWeight(1);
- def RedChgA = if DiffMACD 0 then if DiffMACD[1] DiffMACD[2] and DiffMACD > DiffMACD[1] then 1 else 0 else 0;
- plot RedChg = if RedChgA then high else Double.NaN ;
- RedChg .SetPaintingStrategy(PaintingStrategy.POINTS);
- RedChg .SetDefaultColor(Color.WHITE);
- RedChg .SetLineWeight(1);
- plot RedChgB = if RedChgA then low else Double.NaN ;
- RedChgB .SetPaintingStrategy(PaintingStrategy.POINTS);
- RedChgB .SetDefaultColor(Color.WHITE);
- RedChgB .SetLineWeight(1);
- AddOrder(OrderType.BUY_TO_OPEN, BuyConditionBUY==2, close[0], 5000, Color.ORANGE, Color.BLACK, "Bought @ " + close[0]);
- 20:52 DownTheHatch: mtroche, kindly click on the 'B' just above where you type and get out of BOLD mode.
- 20:52 DownTheHatch: have you entered your code as a study or a strategy?
- 20:57 Mobius: Down.. I've already posted mtroche's code as a study. But it was ignored.
- 20:58 DownTheHatch: yeah, I know, Got some personal experience with people not listening/reading what they are told.
- 21:01 Mobius: Always amazes me.
- 21:03 mtroche: Please, guys, remeber that I am new to coding and ThinkScript. What's the difference between entering my code a a study or strategy? Do you right he coide diferently? I am sorry, but I really do not understand. Could you explain?
- 21:03 DownTheHatch: maybe same reason people blow up their accounts, refuse to pay attention to what's in fromt of them.
- 21:05 DownTheHatch: AddOrder is not allowed in a study.
- 21:05 twoshoes: Mobius, sir. Appreciate your recent update to the ORB study. However, I cannot get the daily range lines to display for previous days. This example is part of a 5 min, 5 day ES chart, with the 'todayonly' option set to "No". ATR Targets display for the last four days, once triggered. Is there a style setting I need to set?
- 21:07 DMonkey: mtroche....https://tlc.thinkorswim.com/center/charting/thinkscript/tutorials.html.....read through all of these and take the quiz at the end of the chapters to get a basic understanding
- 21:08 mtroche: So, that's the problem.... how do I create a startegy? I opened the ciode of noe strategy (MACDStrat), and it loooks to me just like a study with the AddOrder.
- 21:09 Mobius: mtroche - here is your code as a strategy. Needs to be copy and pasted to a NEW STRATEGY.
- # MACD and Awsome Oscillator Strategy
- input fastLength = 12;
- input slowLength = 26;
- input MACDLength = 9;
- input averageType = AverageType.EXPONENTIAL;
- def DiffMACD = MACD(fastLength, slowLength, MACDLength, averageType);
- def AC = AwesomeOscillator() - Average(AwesomeOscillator(), 5);
- def zero = if isNaN(close) then double.nan else 0;
- def upArrow = if DiffMACD crosses above 0 and AC crosses above 0 then 1 else double.nan;
- def dnArrow = if DiffMACD crosses below 0 and AC crosses below 0 then 1 else double.nan;
- addOrder(OrderType.BUY_TO_Open, upArrow);
- addOrder(orderType.Sell_TO_Close, dnArrow);
- 21:12 UpTheCreek: twoshoes, I'm getting multiple days with the most recent ORB code that Mobius posted
- 21:15 syracuse: S&C Magazine, May 2017, Strategy: http://tos.mx/dGNlkr
- 21:17 mtroche: Mobius - Thank you fro the code, but it did not work. I copied it and went to "Edit Studies and Strategies" then to "Strategies" then to "New", and paste it there, but the startegy is not shown.
- 21:21 Mobius: my guess is your chart shows nothing because there's not entries to show. It does work.
- 21:24 Mobius: mtroche - your strategy on a 1 year daily /ES chart showing one entry and one exit
- 21:25 jay44: From recent chats in this room, it appears a HOLY GRAIL is still escaping everyone as there is always a quest for new study/strategy/indicator/scan.
- 21:26 Mobius: mtroche = your strategy on the upper chart and your study on the lower chart showing the arrows where the upper chart does
- 21:26 mtroche: Mobius - PLease, try it withh 1 a i minute. Intertsing enough, I copied and pasted the startegy that syracuse shared in at line 20:15, and both startegies yours and his show in my chart, buyt if I turn off his, your study disapears, too.
- 21:28 Mobius: 2 day 1min chart of /ES Yes it plots on that too
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement