Looking to add a horizontal line for the 21 ema for daily, 1H, 2H and 4H that updates automatically in the chart. Can anyone help me? I’m using the thinkorswim platform and need a script to be able to add those to a single chart.
Ruby:def xemaD = if IsNaN(close) then xemaD[1] else ExpAverage(close(period = AggregationPeriod.DAY), 21); plot emaD = xemaD; emaD.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema4 = if IsNaN(close) then xema4[1] else ExpAverage(close(period = AggregationPeriod.FOUR_HOURS), 21); plot ema4 = xema4; ema4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema2 = if IsNaN(close)...
Looking to add a horizontal line for the 21 ema for daily, 1H, 2H and 4H that updates automatically in the chart. Can anyone help me? I’m using the thinkorswim platform and need a script to be able to add those to a single chart.
Ruby:def xemaD = if IsNaN(close) then xemaD[1] else ExpAverage(close(period = AggregationPeriod.DAY), 21); plot emaD = xemaD; emaD.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema4 = if IsNaN(close) then xema4[1] else ExpAverage(close(period = AggregationPeriod.FOUR_HOURS), 21); plot ema4 = xema4; ema4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema2 = if IsNaN(close) then xema2[1] else ExpAverage(close(period = AggregationPeriod.TWO_HOURS), 21); plot ema2 = xema2; ema2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema1 = if IsNaN(close) then xema1[1] else ExpAverage(close(period = AggregationPeriod.HOUR), 21); plot ema1 = xema1; ema1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); input showbubbles = yes; input bubblemover = 3; def bm = bubblemover; def bm1 = bm + 1; AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), emaD[bm], "D", emaD.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema4[bm], "4", ema4.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema2[bm], "2", ema2.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema1[bm], "1", ema1.TakeValueColor());
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thank you so much. Is there a way that it can be only a straight horizontal line?This has bubble option to assist display.
Thank you so much. Is there a way that it can be only a straight horizontal line?
Ruby:input showtodayonly = yes; def xemaD = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.DAY), 21) else Double.NaN; plot emaD = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xemaD); emaD.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema4 = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.FOUR_HOURS), 21) else Double.NaN; plot ema4 = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xema4); ema4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema2 = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.TWO_HOURS), 21) else Double.NaN; plot ema2 = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xema2); ema2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema1 = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.HOUR), 21) else Double.NaN; plot ema1 = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xema1); ema1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); input showbubbles = yes; input bubblemover = 3; def bm = bubblemover; def bm1 = bm + 1; AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), emaD[bm], "D", emaD.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema4[bm], "4", ema4.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema2[bm], "2", ema2.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema1[bm], "1", ema1.TakeValueColor());
I have an issue. It's currently not showing on the 4HR or the Daily Chart. It only shows on the 1HR and 1min-45minThis has bubble option to assist display.
I have an issue. It's currently not showing on the 4HR or the Daily Chart. It only shows on the 1HR and 1min-45min
Ruby:input showtodayonly = yes; def xemaD = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.DAY), 21) else Double.NaN; plot emaD = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xemaD); emaD.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); def xema4 = if !IsNaN(close) and IsNaN(close[-1]) then ExpAverage(close(period = AggregationPeriod.FOUR_HOURS), 21) else Double.NaN; plot ema4 = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else HighestAll(xema4); ema4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); input showbubbles = yes; input bubblemover = 3; def bm = bubblemover; def bm1 = bm + 1; AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), emaD[bm], "D", emaD.TakeValueColor()); AddChartBubble(showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]), ema4[bm], "4", ema4.TakeValueColor());
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.