Anybody know how to create a bar counter on ToS? I want something that I can count from a specific bar to another specific bar.
declare lower;
#Volume at Specified Time Interval averaged by inputted amount
###Please Keep Code Intact if you share
### By XeoNoX via usethinkscript.com
input StartTime = 0930;
input Endtime = 1030;
##Set Time_Agreggration to match chart timeframe
input Number_to_Average_By = 2;
def na = Double.NaN;
def today=getday()==getlastDay();
def SelectedTime = if GetLastDay() == GetDay() and SecondsFromTime(StartTime) >= 0 and SecondsFromTime(Endtime) < 0 then 1 else 0;
def Selected_Volume = TotalSum(if SelectedTime then volume else 0);
def avg = round((Selected_Volume/Number_to_Average_By),0);
AddLabel (yes,"Total Volume: " + Selected_Volume + " " + Number_to_Average_By + "Bar Avg: " + avg);
i did the very same thing...i came here wanting something, hoping coders would help me...in hindsight they helped me by interacting, responding within the scope of the project, and generally not being huge jerks...which gave me that extra little nudge to keep going...im able to do just a tiny bit more on my own thanx to you guys. For anyone in a similar position, no real background in coding or scripts, we will have to stand on our own two feet...man up and grow, learn, you can do it. Just keep things reasonable at first.@ideallife2day There's always a work-around or minor change in logic... I'd just like to see more members learning to code and less requests for others to do the coding at their whims... I've honestly never seen a forum where so many feel it's ok to just keep asking of others and never learning to help themselves and I've belonged to quite a few forums over the years... Back when I had an open source project forum we'd help those willing to help themselves - unless someone was willing to pay for code... I made a lot of money coding custom modules for large web development projects for other developers and site owners back then... But I still enjoyed seeing members learn to code so they could help themselves... But I digress...
Any indicator or study you make will have value resulted from your study and can not be changed with a click of the mouse. There are drawing tools that you can point and click and get values. https://www.youtube.com/results?search_query=thinkorswim+drawing+toolsI am trying to create a simple fibonacci retracement indicator as an exercise. The first task is to find the prices of two points A and B which are determined by two consecutive price bar selections. The first mouse click on a price chart will be for point A then next click is for point B. I am new to thinkScript. I could not find a solution after googling and reading tutorials. Can anyone help?
Thanks!
@rad14733 Thank you for the suggestion. I have access to Fib tools in TOS. The exercise was trying to grab a price at the bar selected by a mouse click. If this were possible I could have coded tools like Voodoo lines.
#Computes and plots the Zscore
#Provided courtesy of ThetaTrend.com
#Feel free to share the code with a link back to thetatrend.com
declare lower;
input price = close;
input length = 20;
input ZavgLength = 20;
#Initialize values
def oneSD = stdev(price,length);
def avgClose = simpleMovingAvg(price,length);
def ofoneSD = oneSD*price[1];
def Zscorevalue = ((price-avgClose)/oneSD);
def avgZv = average(Zscorevalue,20);
#Compute and plot Z-Score
plot Zscore = ((price-avgClose)/oneSD);
Zscore.setPaintingStrategy(paintingStrategy.HISTOGRAM);
Zscore.setLineWeight(2);
Zscore.assignValueColor(if Zscore > 0 then color.green else color.red);
plot avgZscore = average(Zscorevalue,ZavgLength);
avgZscore.setPaintingStrategy(paintingStrategy.LINE);
#This is an optional plot that will display the momentum of the Z-Score average
#plot momZAvg = (avgZv-avgZv[5]);
#Plot zero line and extreme bands
plot zero = 0;
plot two = 2;
plot negtwo = -2;
plot three = 3;
plot negthree = -3;
zero.setDefaultColor(color.black);
Yes, I try to figure it out before coming here. Heard from several other members here, not trying to look for a free handout. I donated to a food ****ry for help the last time, I am NOT looking for any free handouts.sure, you'd use if statement...im not a coder, i just tried really hard to understand just enough of what i wanted and barely got by...we may be able to do 'if last candle is red then start counting red' and vice versa, 'if green candle then start counting green'. then when it switches from the candle color you're counting it would start over. that's what i would use as the logic in the counter. guess this would improve my coding knowledge so i'll give it a shot if you promise to also try to learn more about this stuff
you can use this as a guide and should be able to accomplish what you are trying to doYes, I try to figure it out before coming here. Heard from several other members here, not trying to look for a free handout. I donated to a food ****ry for help the last time, I am NOT looking for any free handouts.
I figured it would be an if statement. What I am trying to learn is what words/code are already built in to TOS ya know. Like obviously I cant just say, "Count sum of consecutive green candles". I am trying to make it as basic as possible. I have been in the editor looking at what words/phrases I can say.
Total bars on ChartIs there an indicator that shows how many bars on current chart not like the consicative bar count but something that tells you how many bar total on the chart thanks
#Total Bars on Chart
def bar = barnumber();
AddLabel (yes, "Bars on Chart " + (bar) );
Volume percent change from previous bar as label and chart bubbleIs there a way to make a script that will show percentage increase in volume over the previous bar? For example if the first bar shows 5000 volume and the next bar shows 7500 is there a way to make a bubble that shows it increased 50% over the previous bar and will continue rolling over from each successive bar? I do a lot of trading off volume and have to eyeball or factor in my head if something is increasing substantially. Also, having it match red/green respectively on the price/volume bars red for negative and green for positive obviously.
declare lower;
#volume percent change from previous bar as label and chart bubble
#By XeoNoX via request via usethinkscript.com
input show_label = yes;
plot vol= volume;
vol.SetPaintingStrategy( PaintingStrategy.HISTOGRAM );
def volchange = ((volume-volume[1])/volume[1])*100;
AddChartBubble(volchange, volume, round(volchange,2) +"%");
AddLabel (show_label, "Vol Change" + round(volchange,2) + "%" );
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Does Anybody Know of A Predictive Moving Average Script? | Questions | 2 | ||
A | Does anybody know the indicator he is using? | Questions | 2 | |
F | Can anybody help to explain these scripts? | Questions | 4 | |
M | anybody know 1-2-3 Chart Patterns | Questions | 7 | |
M | Trying to create an earnings scan in TOS | Questions | 2 |
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.