ThinkStudy
New member
Anyway to do a Positive Volume Index on TOS that plots a moving average and has customizable inputs?
[/IMG]
[/IMG]
Last edited by a moderator:
What would the final script look like please? Thanks in advance
You want an average ofplot AVG = MovingAverage(AvgType, close, Length);
index
instead of an average of close
.Thank You! That did the trick.You want an average ofindex
instead of an average ofclose
.
it doesnt look like the input priceclose feild is working, everything else is working on it though. do you know how to fix that?You want an average ofindex
instead of an average ofclose
.
priceclose is not used anywhere in the code.it doesnt look like the input priceclose feild is working, everything else is working on it though. do you know how to fix that?
input priceclose = close;
line.def index =
should be priceclose instead of close.What would the final script look like please? Thanks in advance
# ########################################################
# Positive Volume Index
# ########################################################
declare lower;
input AvgType = averageType.SIMPLE;
input Length = 50;
def index = compoundValue(1, index[1] + if (volume > volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);
plot PVI = index;
plot AVG = MovingAverage(AvgType, index, Length);
PVI.SetDefaultColor(GetColor(5));
AVG.SetDefaultColor(color.yellow);
What would the final script look like please? Thanks in advance
Hi I've been trying to write code for this scanner. Specifically for when the 1. avg has reversed direction and showing an inflection point positive and postive slope for at least 2 bars. I also want to incorporate rsi and scan for when rsi is under the avg given the first condition is true.
THIS IS WHAT IM TALKING ABOUT VISUALLY FOR THE AVG LINE
It runs but it gives mixed results and is driving me crazy!!!
script posvolume {
# Positive Volume Index
# ########################################################
# ########################################################
# Positive Volume Index
# ########################################################
declare lower;
input AvgType = averageType.SIMPLE;
input Length = 50;
input priceclose = close;
def index = compoundValue(1, index[1] + if (volume > volume[1] and priceclose[1] != 0) then 100 * (priceclose - priceclose[1]) / priceclose[1] else 0, 100);
plot PVI = index;
plot AVG = MovingAverage(AvgType, index, Length);
PVI.SetDefaultColor(GetColor(5));
AVG.SetDefaultColor(color.yellow);
}
input AvgType = AverageType.EXPONENTIAL;
input Length = 30;
input priceclose = close;
def index = CompoundValue(1, index[1] + if (volume > volume[1] and priceclose[1] != 0) then 100 * (priceclose - priceclose[1]) / priceclose[1] else 0, 100);
def PVI = index;
def AVG = MovingAverage(AvgType, index, Length);
def condition2 = posvolume("length" = 30)."avg" > posvolume("length" = 30)."avg"[1] within 1 bar;
def condition3 = RSI < AVG within 1 bar;
plot example = condition2 and condition3 is true within 1 bar;
Hi, I have a question, when the Volume goes below Moving average, does it mean the momentum is decreasing and Bears are getting nervous?Ruby:# ######################################################## # Positive Volume Index # ######################################################## declare lower; input AvgType = averageType.SIMPLE; input Length = 50; def index = compoundValue(1, index[1] + if (volume > volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100); plot PVI = index; plot AVG = MovingAverage(AvgType, index, Length); PVI.SetDefaultColor(GetColor(5)); AVG.SetDefaultColor(color.yellow);
Hi Conmayne, you have two moving averages and the their inputs named the same, I believe they should be different, input and input1,....
Hi I've been trying to write code for this scanner. Specifically for when the 1. AVG has reversed direction and showing an inflection point positive and positive slope for at least 2 bars. I also want to incorporate rsi and scan for when rsi is under the avg given the first condition is true. IS IT POSSIBLE TO REPLACE PVI WITH RSI ON THE STUDY???
THIS IS WHAT IM TALKING ABOUT VISUALLY FOR THE AVG LINE
input AvgType = AverageType.EXPONENTIAL;
input Length = 30;
input priceclose = close;
def index = CompoundValue(1, index[1] + if (volume > volume[1] and priceclose[1] != 0) then 100 * (priceclose - priceclose[1]) / priceclose[1] else 0, 100);
def PVI = index;
def AVG = MovingAverage(AvgType, index, Length);
def condition2 = posvolume("length" = 30)."avg" > posvolume("length" = 30)."avg"[1] within 1 bar;
def condition3 = RSI < AVG within 1 bar; (OBVIOUSLY I KNOW THIS WONT WORK BUT THIS IS THE CONDITION I WANT TO CODE FOR INCLUDED IN MY SCANNER AND STUDY)
plot example = condition2 and condition3 is true within 1 bar;
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.