Need help with Strat Number Code and hiding some of the numbers

jr2146

New member
I wanted to know if someone can please help me with a TOS study/code, Below is the Strat Number Study/Code and all I want is to be able to hide all the numbers above and below the candles except for just like the past 3 or 4 numbers on the candles so the chart will look clean and not show all the numbers on the candles.

Here is the TOS chart link with the study/code.
http://tos.mx/yjlTdvu

Image in:
Any help would be appreciated. Thank you.
 
Last edited:
Solution
I wanted to know if someone can please help me with a TOS study/code, Below is the Strat Number Study/Code and all I want is to be able to hide all the numbers above and below the candles except for just like the past 3 or 4 numbers on the candles so the chart will look clean and not show all the numbers on the candles.

Here is the TOS chart link with the study/code.
http://tos.mx/yjlTdvu

Image in:
Any help would be appreciated. Thank you.

en will be true on the last 4 bars of the chart
add en to the plot formulas, with and,

input lastbars = 4;
def en = (!isnan(close) and isnan(close[-lastbars]));
I wanted to know if someone can please help me with a TOS study/code, Below is the Strat Number Study/Code and all I want is to be able to hide all the numbers above and below the candles except for just like the past 3 or 4 numbers on the candles so the chart will look clean and not show all the numbers on the candles.

Here is the TOS chart link with the study/code.
http://tos.mx/yjlTdvu

Image in:
Any help would be appreciated. Thank you.

en will be true on the last 4 bars of the chart
add en to the plot formulas, with and,

input lastbars = 4;
def en = (!isnan(close) and isnan(close[-lastbars]));
 
Solution
@halcyonguy thanks for this, only question is where exactly do I put the def en = (!isnan(close) and isnan(close[-lastbars])); as I have tried multiple places in the plot and even added the and and was not able to figure it out to get it to work correctly as I don't know how to code but trying to learn a little bit.. here is what I have tried, i put the def at the end of the first Plot but still showing all numbers as I put the code in the plot.

#------------------------------------
# S T R A T N U M B E R S
#
# A study by Ramon DV. aka Pelonsax
#
# Version 1.0 8/01/20
#
# Version 2.0 8/4/20 Corrected errors in logic for scenarios
#
#------------------------------------
#------------------------------------
# DEFINE SCENARIOS
#------------------------------------
def H = high;
def L = low;
def C = close;
def O = open;

def insidebar = (H < H[1] and L > L[1]) or (H == H[1] and L > L[1]) or (H < H[1] and L == L[1]) or (H == H[1] and L == L[1]);
def outsidebar = H > H[1] and L < L[1];
def twoup = H > H[1] and L >= L[1];
def twodown = H <= H[1] and L < L[1];

#------------------------------------
# STRAT NUMBERS
#------------------------------------
input Show_Strat_Numbers = yes;
input Show_Twos = yes;
input lastbars = 4;


plot barType = if Show_Strat_Numbers and insidebar then 1 else if Show_Strat_Numbers and outsidebar then 3 else Double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(color.WHITE);def en = (!isnan(close) and isnan(close[-lastbars]));

plot barTypeDN = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twodown then 2 else Double.NaN;
barTypeDN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barTypeDN.AssignValueColor(color.DOWNTICK);

plot barTypeUP = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twoup then 2 else Double.NaN;
barTypeUP.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barTypeUP.AssignValueColor(color.UPTICK);


any help would be great.. thank you
 
@halcyonguy I have tried everything to get the code to work with what you gave me on the last post and still not able to get it to show only the last few numbers and hide all the other strat numbers. Also I am not a coder so I am doing it all trial and error and just cant figure it out..

Would you be able to add the code you gave me into the orig code so it will work? Thank you in advance.
 
@halcyonguy I have tried everything to get the code to work with what you gave me on the last post and still not able to get it to show only the last few numbers and hide all the other strat numbers. Also I am not a coder so I am doing it all trial and error and just cant figure it out..

Would you be able to add the code you gave me into the orig code so it will work? Thank you in advance.

This should limit the number of each 3 types to the input limit_numbers_display = 2 is used in image below

Screenshot-2023-01-31-092233.png
Code:
#------------------------------------
# S T R A T N U M B E R S
#
# A study by Ramon DV. aka Pelonsax
#
# Version 1.0 8/01/20
#
# Version 2.0 8/4/20 Corrected errors in logic for scenarios
#
#------------------------------------
#------------------------------------
# DEFINE SCENARIOS
#------------------------------------
def H = high;
def L = low;
def C = close;
def O = open;

def insidebar = (H < H[1] and L > L[1]) or (H == H[1] and L > L[1]) or (H < H[1] and L == L[1]) or (H == H[1] and L == L[1]);
def outsidebar = H > H[1] and L < L[1];
def twoup = H > H[1] and L >= L[1];
def twodown = H <= H[1] and L < L[1];

#------------------------------------
# STRAT NUMBERS
#------------------------------------
input Show_Strat_Numbers = yes;
input Show_Twos = yes;
input lastbars = 4;
input limit_numbers_display = 2;

def x = if insidebar or outsidebar then x[1] + 1 else x[1];

plot barType = if Show_Strat_Numbers and insidebar and HighestAll(x) - x <= limit_numbers_display - 1 then 1 else if Show_Strat_Numbers and outsidebar and HighestAll(x) - x <= limit_numbers_display - 1 then 3 else Double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(Color.WHITE);
def en = (!IsNaN(close) and IsNaN(close[-lastbars]));

def y = if !insidebar and !outsidebar and twodown then y[1] + 1 else y[1];
plot barTypeDN = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twodown and HighestAll(y) - y <= limit_numbers_display - 1 then 2 else Double.NaN;
barTypeDN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barTypeDN.AssignValueColor(Color.DOWNTICK);

def z = if !insidebar and !outsidebar and twoup then z[1] + 1 else z[1];

plot barTypeUP = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twoup  and HighestAll(z) - z <= limit_numbers_display - 1 then 2 else Double.NaN;
barTypeUP.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barTypeUP.AssignValueColor(Color.UPTICK);
 
@halcyonguy thanks for this, only question is where exactly do I put the def en = (!isnan(close) and isnan(close[-lastbars])); as I have tried multiple places in the plot and even added the and and was not able to figure it out to get it to work correctly as I don't know how to code but trying to learn a little bit.. here is what I have tried, i put the def at the end of the first Plot but still showing all numbers as I put the code in the plot.

#------------------------------------
# S T R A T N U M B E R S
#
# A study by Ramon DV. aka Pelonsax
#
# Version 1.0 8/01/20
#
# Version 2.0 8/4/20 Corrected errors in logic for scenarios
#
#------------------------------------
#------------------------------------
# DEFINE SCENARIOS
#------------------------------------
def H = high;
def L = low;
def C = close;
def O = open;

def insidebar = (H < H[1] and L > L[1]) or (H == H[1] and L > L[1]) or (H < H[1] and L == L[1]) or (H == H[1] and L == L[1]);
def outsidebar = H > H[1] and L < L[1];
def twoup = H > H[1] and L >= L[1];
def twodown = H <= H[1] and L < L[1];

#------------------------------------
# STRAT NUMBERS
#------------------------------------
input Show_Strat_Numbers = yes;
input Show_Twos = yes;
input lastbars = 4;


plot barType = if Show_Strat_Numbers and insidebar then 1 else if Show_Strat_Numbers and outsidebar then 3 else Double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(color.WHITE);def en = (!isnan(close) and isnan(close[-lastbars]));

plot barTypeDN = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twodown then 2 else Double.NaN;
barTypeDN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barTypeDN.AssignValueColor(color.DOWNTICK);

plot barTypeUP = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twoup then 2 else Double.NaN;
barTypeUP.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barTypeUP.AssignValueColor(color.UPTICK);


any help would be great.. thank you


@SleepyZ thanks for replying with an answer. sometimes i forget to get back to a post.

@jr2146 sleepyz posted an answer in post5, not me.

------------------------

here is my version of what i had in mind.
pick a quantity of bars, and display the numbers on just those last x bars on the chart.
i suggested adding a formula for EN, and adding EN to some formulas.

input lastbars = 7;
def en = (!IsNaN(close) and IsNaN(close[-lastbars]));

EN will be true during the last 7 bars on the chart.

i intended EN to be added to the plot formulas.
i didn't look at the study before , i rarely load links. i didn't realize the plot formulas were so long and complicated.
since there are several IFs in the plot formulas, it was easier to add the inverse of en to the beginning of each plot formula.

if bar is not during the desired last 7 bars , then nan (don't plot anything).

= if !en then na else if ...




Code:
# stratnumbers_lastbars_00a

#------------------------------------
# S T R A T N U M B E R S
#
# A study by Ramon DV. aka Pelonsax
# Version 1.0 8/01/20
# Version 2.0 8/4/20 Corrected errors in logic for scenarios
#
#------------------------------------


#------------------------------------
# DEFINE SCENARIOS
#------------------------------------

def na = double.nan;

def H = high;
def L = low;
def C = close;
def O = open;

def insidebar = (H < H[1] and L > L[1]) or (H == H[1] and L > L[1]) or (H < H[1] and L == L[1]) or (H == H[1] and L == L[1]);
def outsidebar = H > H[1] and L < L[1];
def twoup = H > H[1] and L >= L[1];
def twodown = H <= H[1] and L < L[1];

#------------------------------------
# STRAT NUMBERS
#------------------------------------
input Show_Strat_Numbers = yes;
input Show_Twos = yes;
input lastbars = 7;
def en = (!IsNaN(close) and IsNaN(close[-lastbars]));

plot barType = if !en then na else if Show_Strat_Numbers and insidebar then 1 else if Show_Strat_Numbers and outsidebar then 3 else Double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(color.WHITE);

plot barTypeDN = if !en then na else if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twodown then 2 else Double.NaN;
barTypeDN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barTypeDN.AssignValueColor(color.DOWNTICK);

plot barTypeUP = if !en then na else if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twoup then 2 else Double.NaN;
barTypeUP.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barTypeUP.AssignValueColor(color.UPTICK);

#----------------------
#  test
addchartbubble(0 and en , low, "-", (if en then color.yellow else color.gray), no);
#
 

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
218 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