We have moved to Discord. Please click here to join us in the Trading Terminal Discord server.
These forums are read-only.
Leaderboard
Popular Content
Showing content with the highest reputation on 08/12/2022 in Posts
-
1 pointDoes DAS have a snap feature that allows horizontal lines to snap to OHLC of candles to make drawing them faster and more accurate?
-
1 pointI definitely saw problems on Monday, however on Tuesday, the values lined up...so it may have something to do with "previous day" looking at Sunday, and not the previous trading day (Friday). Also, I found the following bit of code that when inserted into yours, seems to grab the close at 2000: def sessionopen=1945; def sessionclose=1955; So the following includes the modifications (I also added some labeling bubbles), and checking SPY on TOS to DAS, the levels line up perfectly on Tuesday: R4 = 412.89 (TOS) vs 412.885 (DAS) and S4 = 407.37 (TOS) vs 407.375 (DAS). NVDA, MSFT, and other stocks appeared to match as well. The code didn't work on Monday, however, which again I think has something to do with the weekend and what day TOS was trying to grab data from. I'm only a "cut, copy, and paste coder," so I really can't decipher or solve the issue here unfortunately...just a hunch. input aggregationPeriod = {default "DAY", "WEEK", "MONTH"}; input length = 1; input SetClose = 0.00; input PreMaketHigh = 0.00; input PreMaketLow = 0.00; input hide_s1_r1 = yes; input hide_s2_r2 = yes; input showbubbles_description = yes; input showpricebubble = yes; def sessionopen=1945; def sessionclose=1955; Assert(length > 0, "'length' should be positive: " + length); def yyyymmdd = GetYYYYMMDD(); def month = GetYear() * 12 + GetMonth(); def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd)); def Today = GetDay() == GetLastDay(); def Yesterday = GetDay() == GetLastDay() - 1; def period; switch (aggregationPeriod) { case DAY: period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1; case WEEK: period = Floor(day_number / 7); case MONTH: period = Floor(month - First(month)); } def prevHigh = if YesterDay and !YesterDay[1] then high else if Yesterday and high > prevHigh[1] then high else prevHigh[1]; def prevLow = if Yesterday and !Yesterday[1] then low else if Yesterday and low < prevLow[1] then low else prevLow[1]; def camhighValue = if PreMaketHigh == 0 then prevHigh else PreMaketHigh; def camlowValue = if PreMaketLow == 0 then prevLow else PreMaketLow; def last = if Today and !Today[1] then close[1] else last[1]; def range = camhighValue - camlowValue; input start = 1945; input marketClose = 1955; def closeCounter = SecondsTillTime(marketClose) >= 0 and SecondsFromTime(start) >= 0; rec camClose = if closecounter and !isnan(close) then close else camClose[1]; plot R6 = (camhighValue / camlowValue) * camClose; plot R4 = camClose + range * (1.1) / 2; plot R3 = camClose + range * (1.1) / 4; plot R2 = camClose + range * (1.1) / 6; plot R1 = camClose + range * (1.1) / 12; plot S1 = camClose - range * (1.1) / 12; plot S2 = camClose - range * (1.1) / 6; plot S3 = camClose - range * (1.1) / 4; plot S4 = camClose - range * (1.1) / 2; plot S6 = (camClose - (R6 - camClose)); R1.SetHiding(hide_s1_r1); S1.SetHiding(hide_s1_r1); R2.SetHiding(hide_s2_r2); S2.SetHiding(hide_s2_r2); R6.SetDefaultColor(GetColor(5)); R4.SetDefaultColor(GetColor(5)); R3.SetDefaultColor(GetColor(5)); R2.SetDefaultColor(GetColor(5)); R1.SetDefaultColor(GetColor(5)); S1.SetDefaultColor(GetColor(6)); S2.SetDefaultColor(GetColor(6)); S3.SetDefaultColor(GetColor(6)); S4.SetDefaultColor(GetColor(6)); S6.SetDefaultColor(GetColor(6)); def paintingStrategy = if aggregationPeriod == aggregationPeriod.DAY then PaintingStrategy.POINTS else if aggregationPeriod == aggregationPeriod.WEEK then PaintingStrategy.TRIANGLES else PaintingStrategy.SQUARES; R6.SetPaintingStrategy(paintingStrategy); R4.SetPaintingStrategy(paintingStrategy); R3.SetPaintingStrategy(paintingStrategy); R2.SetPaintingStrategy(paintingStrategy); R1.SetPaintingStrategy(paintingStrategy); S1.SetPaintingStrategy(paintingStrategy); S2.SetPaintingStrategy(paintingStrategy); S3.SetPaintingStrategy(paintingStrategy); S4.SetPaintingStrategy(paintingStrategy); S6.SetPaintingStrategy(paintingStrategy); #Bubbles to describe Pivot Levels input bubblemover = -40; def n = bubblemover; def n1 = n + 1; def StartPlot = if showbubbles_description == yes then (IsNaN(close[n]) and !IsNaN(close[n1])) else Double.NaN; AddChartBubble(StartPlot, R6[n1], "R6 " + (if showpricebubble then AsText(R6[n1]) else ""), Color.RED, if close[n1] > R6[n1] then no else yes); AddChartBubble(StartPlot, R4[n1], "R4 " + (if showpricebubble then AsText(R4[n1]) else ""), Color.YELLOW, if close[n1] > R4[n1] then no else yes); AddChartBubble(StartPlot, R3[n1], "R3 " + (if showpricebubble then AsText(R3[n1]) else ""), Color.RED, if close[n1] > R3[n1] then no else yes); AddChartBubble(StartPlot and hide_s2_r2 == no, R2[n1], "R2 " + (if showpricebubble then AsText(R2[n1]) else ""), Color.GREEN, if close[n1] > R2[n1] then no else yes); AddChartBubble(StartPlot and hide_s1_r1 == no, R1[n1], "R1 " + (if showpricebubble then AsText(R1[n1]) else ""), Color.GREEN, if close[n1] > R1[n1] then no else yes); AddChartBubble(StartPlot, S6[n1], "S6 " + (if showpricebubble then AsText(S6[n1]) else ""), Color.GREEN, if close[n1] > S6[n1] then no else yes); AddChartBubble(StartPlot, S4[n1], "S4 " + (if showpricebubble then AsText(S4[n1]) else ""), Color.YELLOW, if close[n1] > S4[n1] then no else yes); AddChartBubble(StartPlot, S3[n1], "S3 " + (if showpricebubble then AsText(S3[n1]) else ""), Color.GREEN, if close[n1] > S3[n1] then no else yes); AddChartBubble(StartPlot and hide_s2_r2 == no, S2[n1], "S2 " + (if showpricebubble then AsText(S2[n1]) else ""), Color.RED, if close[n1] > S2[n1] then no else yes); AddChartBubble(StartPlot and hide_s1_r1 == no, S1[n1], "S1 " + (if showpricebubble then AsText(S1[n1]) else ""), Color.RED, if close[n1] > S1[n1] then no else yes); R1.HideBubble(); R2.HideBubble(); R3.HideBubble(); R4.HideBubble(); R6.HideBubble(); S1.HideBubble(); S2.HideBubble(); S3.HideBubble(); S4.HideBubble(); S6.HideBubble();
-
1 pointThanks for this share @Kevin Gong! If you are interested in ever using Cams without premarket data (for example, per Thor, when today's premarket range falls within yesterday's daily range), the script below is much better than the standard one in TOS. Just be sure to change aggregation period to "1". I've checked between TOS and DAS and the values mirror very closely the cams provided when using "without premarket data." input aggregationPeriod = {default "DAY", "WEEK", "MONTH"}; input length = 25; input hide_s1_r1 = yes; input lines = {default dashes, points, triangles, horizontal, squares}; input showbubbles_description = yes; input showpricebubble = yes; Assert(length > 0, "'length' should be positive: " + length); def yyyymmdd = GetYYYYMMDD(); def month = GetYear() * 12 + GetMonth(); def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd)); def period; switch (aggregationPeriod) { case DAY: period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1; case WEEK: period = Floor(day_number / 7); case MONTH: period = Floor(month - First(month)); } def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % length else count[1], 0); def start = CompoundValue(1, count < count[1] + period - period[1], yes); def highValue = if start then Highest(high(period = aggregationPeriod), length)[1] else if highValue[1] != 0 then highValue[1] else Double.NaN; def lowValue = if start then Lowest(low(period = aggregationPeriod), length)[1] else if lowValue[1] != 0 then lowValue[1] else Double.NaN; def closeValue = if start then close(period = aggregationPeriod)[1] else closeValue[1]; def range = highValue - lowValue; def PH = high(period = aggregationPeriod)[1]; def PL = low(period = aggregationPeriod)[1]; def PC = close(period = aggregationPeriod)[1]; plot HH; plot PP; plot LL; HH = PH; LL = PL; PP = (PH + PL + PC) / 3; HH.SetStyle(Curve.MEDIUM_DASH); LL.SetStyle(Curve.MEDIUM_DASH); plot R6 = (highValue / lowValue) * closeValue; plot R4 = closeValue + range * (1.1) / 2; plot R3 = closeValue + range * (1.1) / 4; plot R5 = r4 + 1.168 * (R4 – R3); plot R2 = closeValue + range * (1.1) / 6; plot R1 = closeValue + range * (1.1) / 12; plot S1 = closeValue - range * (1.1) / 12; plot S2 = closeValue - range * (1.1) / 6; plot S3 = closeValue - range * (1.1) / 4; plot S4 = closeValue - range * (1.1) / 2; plot S5 = S4-1.168 * (s3 - s4); plot S6 = (closeValue - (R6 - closeValue)); R1.SetHiding(hide_s1_r1); S1.SetHiding(hide_s1_r1); R6.SetDefaultColor(GetColor(6)); R5.SetDefaultColor(GetColor(6)); R4.SetDefaultColor(GetColor(6)); R3.SetDefaultColor(GetColor(6)); R2.SetDefaultColor(GetColor(6)); R1.SetDefaultColor(GetColor(6)); S1.SetDefaultColor(GetColor(5)); S2.SetDefaultColor(GetColor(5)); S3.SetDefaultColor(GetColor(5)); S4.SetDefaultColor(GetColor(5)); S5.SetDefaultColor(GetColor(5)); S6.SetDefaultColor(GetColor(5)); def paintingStrategy = if lines == lines.points then PaintingStrategy.POINTS else if lines == lines.triangles then PaintingStrategy.TRIANGLES else if lines == lines.dashes then PaintingStrategy.DASHES else if lines == lines.horizontal then PaintingStrategy.HORIZONTAL else PaintingStrategy.SQUARES; R6.SetPaintingStrategy(paintingStrategy); R5.SetPaintingStrategy(paintingStrategy); R4.SetPaintingStrategy(paintingStrategy); R3.SetPaintingStrategy(paintingStrategy); R2.SetPaintingStrategy(paintingStrategy); R1.SetPaintingStrategy(paintingStrategy); S1.SetPaintingStrategy(paintingStrategy); S2.SetPaintingStrategy(paintingStrategy); S3.SetPaintingStrategy(paintingStrategy); S4.SetPaintingStrategy(paintingStrategy); S5.SetPaintingStrategy(paintingStrategy); S6.SetPaintingStrategy(paintingStrategy); #Bubbles to describe Pivot Levels input bubblemover = 8; def n = bubblemover; def n1 = n + 1; def StartPlot = if showbubbles_description == yes then (IsNaN(close[n]) and !IsNaN(close[n1])) else Double.NaN; AddChartBubble(StartPlot, R6[n1], "R6 " + (if showpricebubble then AsText(R6[n1]) else ""), Color.GREEN, if close[n1] > R6[n1] then no else yes); AddChartBubble(StartPlot, R5[n1], "R5 " + (if showpricebubble then AsText(R5[n1]) else ""), Color.GREEN, if close[n1] > R5[n1] then no else yes); AddChartBubble(StartPlot, R4[n1], "R4 " + (if showpricebubble then AsText(R4[n1]) else ""), Color.GREEN, if close[n1] > R4[n1] then no else yes); AddChartBubble(StartPlot, R3[n1], "R3 " + (if showpricebubble then AsText(R3[n1]) else ""), Color.GREEN, if close[n1] > R3[n1] then no else yes); AddChartBubble(StartPlot, R2[n1], "R2 " + (if showpricebubble then AsText(R2[n1]) else ""), Color.GREEN, if close[n1] > R2[n1] then no else yes); AddChartBubble(StartPlot and hide_s1_r1 == no, R1[n1], "R1 " + (if showpricebubble then AsText(R1[n1]) else ""), Color.GREEN, if close[n1] > R1[n1] then no else yes); AddChartBubble(StartPlot, S6[n1], "S6 " + (if showpricebubble then AsText(S6[n1]) else ""), Color.RED, if close[n1] > S6[n1] then no else yes); AddChartBubble(StartPlot, S5[n1], "S5 " + (if showpricebubble then AsText(S5[n1]) else ""), Color.RED, if close[n1] > S5[n1] then no else yes); AddChartBubble(StartPlot, S4[n1], "S4 " + (if showpricebubble then AsText(S4[n1]) else ""), Color.RED, if close[n1] > S4[n1] then no else yes); AddChartBubble(StartPlot, S3[n1], "S3 " + (if showpricebubble then AsText(S3[n1]) else ""), Color.RED, if close[n1] > S3[n1] then no else yes); AddChartBubble(StartPlot, S2[n1], "S2 " + (if showpricebubble then AsText(S2[n1]) else ""), Color.RED, if close[n1] > S2[n1] then no else yes); AddChartBubble(StartPlot and hide_s1_r1 == no, S1[n1], "S1 " + (if showpricebubble then AsText(S1[n1]) else ""), Color.RED, if close[n1] > S1[n1] then no else yes); R1.HideBubble(); R2.HideBubble(); R3.HideBubble(); R4.HideBubble(); R5.HideBubble(); R6.HideBubble(); S1.HideBubble(); S2.HideBubble(); S3.HideBubble(); S4.HideBubble(); S5.HideBubble(); S6.HideBubble();
