Help With Custom Price & Volume Trending Script

cfire23

New member
Greetings all,

thank you in advance for any and all assistance with creating a custom ToS script that plots UpArrow below candle where the high is greater than high of previous candle and volume is greater than volume of previous candle/bar. below is the draft script but it doesn't work - please help to get the script to work.

input length = 10;
input paintBars = yes;
input averageType = AverageType.WILDERS;
input price = volume;
input percent = 2;
input Choice = {default greater, less};

def x = 100*(price / price[length]-1);
plot scan;

switch (Choice){
case greater:
scan = x >= percent;
case less:
scan = x <= -percent;
}

DefineGlobalColor("Positive", Color.UPTICK);


plot greenarrow = if high is greater than high from 1 bars ago and Choice is greater than Choice from 1 bars ago then plotLow else Double.NaN;
greenarrow.SetDefaultColor(color.green);
greenarrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
greenarrow.SetLineWeight(2);
greenarrow.HideBubble() ;
greenarrow.HideTitle() ;
 
Solution
Greetings all,

thank you in advance for any and all assistance with creating a custom ToS script that plots UpArrow below candle where the high is greater than high of previous candle and volume is greater than volume of previous candle/bar. below is the draft script but it doesn't work - please help to get the script to work.

input length = 10;
input paintBars = yes;
input averageType = AverageType.WILDERS;
input price = volume;
input percent = 2;
input Choice = {default greater, less};

def x = 100*(price / price[length]-1);
plot scan;

switch (Choice){
case greater:
scan = x >= percent;
case less:
scan = x <= -percent;
}

DefineGlobalColor("Positive", Color.UPTICK);


plot greenarrow = if high is greater than high...
Greetings all,

thank you in advance for any and all assistance with creating a custom ToS script that plots UpArrow below candle where the high is greater than high of previous candle and volume is greater than volume of previous candle/bar. below is the draft script but it doesn't work - please help to get the script to work.

input length = 10;
input paintBars = yes;
input averageType = AverageType.WILDERS;
input price = volume;
input percent = 2;
input Choice = {default greater, less};

def x = 100*(price / price[length]-1);
plot scan;

switch (Choice){
case greater:
scan = x >= percent;
case less:
scan = x <= -percent;
}

DefineGlobalColor("Positive", Color.UPTICK);


plot greenarrow = if high is greater than high from 1 bars ago and Choice is greater than Choice from 1 bars ago then plotLow else Double.NaN;
greenarrow.SetDefaultColor(color.green);
greenarrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
greenarrow.SetLineWeight(2);
greenarrow.HideBubble() ;
greenarrow.HideTitle() ;

this is easier if each condition is set to a variable, then the variables used in the plot.

regarding this line,
plot greenarrow = if high is greater than high from 1 bars ago and Choice is greater than Choice from 1 bars ago then plotLow else Double.NaN;

...you can't reference an input variable this way. this is how you check the value of an input variable,
if choice == choice.greater then 1 else 0

...Choice is greater than Choice from 1 bars ago. even if it did work, it makes no sense. choice is a word, not a value. so one word can't be greater than another. did you mean to use x?

...plotlow isn't defined , so there is no value to plot.

maybe this will help
here is an alternative, based on using x instead of choice, and low instead of plot low.
Code:
# def h1 = high is greater than high from 1 bars ago
# same thing, coded differently
def h1 = (high > high[1]);

def x1 = (x > x[1]);

plot greenarrow = if ( h1 and x1) then low else Double.NaN;





EDIT .
actually almost nothing in your code is related to your rules statement

if this is what you want

plots UpArrow when ,
...high is greater than high of previous candle
and
...volume is greater than volume of previous candle

see how i separated each condition on its own line. it makes it easier to read and code.
then try this

Code:
def hup = ( high > high[1] );
def vup = ( volume > volume[1] );

plot z = if (hup and vup) then low else double.nan;
z.SetDefaultColor(color.green);
z.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z.SetLineWeight(2);
z.HideBubble() ;
#
 
Last edited:
Solution
this is easier if each condition is set to a variable, then the variables used in the plot.

regarding this line,
plot greenarrow = if high is greater than high from 1 bars ago and Choice is greater than Choice from 1 bars ago then plotLow else Double.NaN;

...you can't reference an input variable this way. this is how you check the value of an input variable,
if choice == choice.greater then 1 else 0

...Choice is greater than Choice from 1 bars ago. even if it did work, it makes no sense. choice is a word, not a value. so one word can't be greater than another. did you mean to use x?

...plotlow isn't defined , so there is no value to plot.

maybe this will help
here is an alternative, based on using x instead of choice, and low instead of plot low.
Code:
# def h1 = high is greater than high from 1 bars ago
# same thing, coded differently
def h1 = (high > high[1]);

def x1 = (x > x[1]);

plot greenarrow = if ( h1 and x1) then low else Double.NaN;





EDIT .
actually almost nothing in your code is related to your rules statement

if this is what you want

plots UpArrow when ,
...high is greater than high of previous candle
and
...volume is greater than volume of previous candle

see how i separated each condition on its own line. it makes it easier to read and code.
then try this

Code:
def hup = ( high > high[1] );
def vup = ( volume > volume[1] );

plot z = if (hup and vup) then low else double.nan;
z.SetDefaultColor(color.green);
z.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z.SetLineWeight(2);
z.HideBubble() ;
#
Is there a way to get alerts on current open positions on ThinkorSwim for high of day greater than previous day high or low of day less than previous low of day?

I have created a scan for general tickers, just thinking of adding openP/L script or something to identify my positions price action.

#High of Day greater than Previous Day High
plot hup = ( high("period" = AggregationPeriod.DAY) > high("period" = AggregationPeriod.DAY )from 1 bar ago );

Thank You!
 
Is there a way to get alerts on current open positions on ThinkorSwim for high of day greater than previous day high or low of day less than previous low of day?

I have created a scan for general tickers, just thinking of adding openP/L script or something to identify my positions price action.

#High of Day greater than Previous Day High
plot hup = ( high("period" = AggregationPeriod.DAY) > high("period" = AggregationPeriod.DAY )from 1 bar ago );

Thank You!
i am not sure about creating a scan. There might be some way to make a study and use getquantity() , to check for existing positions.
Then combine that true/false, with other conditions.

https://usethinkscript.com/threads/...quities-in-thinkorswim.7089/page-4#post-84253

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio/GetQuantity
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
284 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top