Hi all, anyone have a script that can do the average of the last 5 candles for price plot on screen. similar idea, but an average length price of the last 5 bars to apply to daily or intraday. Thank you
Code:input length = 5; AddChartBubble(!IsNaN(close), high, AsText(Sum(close, length) / length), Color.WHITE);
thank you Sleepz! having trouble adding it to script, am i missing a formula
this is perfect, works now.
Question, it is plotting the actual price, I may have explained incorrectly. looking for the actual price length of the candle. For example if a candle is a 50 cent move, over the last 5 candles average. not sure if i am explaining right.
Tank you sleepyz
Code:input length = 5; input diff = .50; def avg_prior_x_bars = Sum(close[1] - open[1], length) / length; def currentdiff = close - open - avg_prior_x_bars ; def cond = currentdiff > diff; AddChartBubble(!IsNaN(close) and cond, high, "Curr - Avg " + astext(currentdiff) , Color.WHITE); input show_debugging = yes; AddChartBubble(show_debugging and !IsNaN(close) and cond, high, "AvgDiff " + " " +astext(avg_prior_x_bars) , Color.WHITE); AddChartBubble(show_debugging and !IsNaN(close) and cond, high, "CurrDiff " + " " +astext(close-open) , Color.WHITE);
You can change the input for the .50 to whatever you want. I just used it to match your example. If you want to see all of the bars have bubbles with the Curr Diff and Avg Diff, just set the 'input diff' to 0 (zero)Hi Sleepyz. I was using the .50 cents as just as an example. If there were 5 bars. Gme went from $200 to $202 thats a 2 dollar bar move. And the first GME bar was a move of $2.00 lets say. the Second a move of $5, the Third a move of $3, the fourth a move of $.75 and the fifth a move of $2..the Firth bar would show not only the current price move but also the average of the last five. So each bar would show the current and last 5 average of the price moves. so the point is to show the average of the length of the price move for the last five bars. the 50 cents was just an example.
i didn't understand the posters number scheme, so i just made up the those numbers 1 to 4, they don't mean anything. i thought they could be used or changed to suit someone's need.The indicator is fantastic. Can anyone please explain the meaning of the numbers 1 to 4.What number is bullish and which number is bearish. I figured out the calculation. TIA
Hi Sleepyz. Would there be a way to get the calculations to perhaps pop up as bars at the top of the screen instead of as bubbles. What i am interested in is the average price move of the last 5 candles depending on if i select, 5 min, 10 min etc. Much appreciated.You can change the input for the .50 to whatever you want. I just used it to match your example. If you want to see all of the bars have bubbles with the Curr Diff and Avg Diff, just set the 'input diff' to 0 (zero)
Hi Sleepyz. Would there be a way to get the calculations to perhaps pop up as bars at the top of the screen instead of as bubbles. What i am interested in is the average price move of the last 5 candles depending on if i select, 5 min, 10 min etc. Much appreciated.
Code:declare lower; input length = 5; input agg = aggregationPeriod.FIVE_MIN; def avg_prior_x_bars = Sum(close(period=agg)[1] - open(period=agg)[1], length) / length; AddChartBubble(!IsNaN(close) , 100, agg/60000+"m \n" + astext(avg_prior_x_bars) , if avg_prior_x_bars>=0 then color.light_green else color.pink); plot x105 = 105; plot x100 = 100; plot x0 = 0; x105.setdefaultColor(color.black); x100.setdefaultColor(color.black); x0.setdefaultColor(color.black);
thank you! i added this, but nothing is popping up. am i doing something wrong?
As I mentioned above, the default is 5 min. Your chart is set to 15 min. Change the input to 15 min or greater at the edit screen for NewStudy7 above.thank you Rad14733.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.