trying to get a condition

Piper2808t

Member
2019 Donor
VIP
hello trying to get this condition in a code




current line of code is plot signaldown = if warning then high else Double.NaN;
need it to be plot signaldown = if three warning(s) occur within 10bars then high else Double.NaN; any help thanks
 
Solution
hello trying to get this condition in a code

current line of code is plot signaldown = if warning then high else Double.NaN;
need it to be plot signaldown = if three warning(s) occur within 10bars then high else Double.NaN; any help thanks

replace this
def warning = ...
with your actual formula

if the boolean signal warning is true 3x, within 10 bars, then high and plot a down arrow.

Code:
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

plot signaldown = if warn then high else Double.NaN;
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#

halcyonguy

Well-known member
VIP
Lifetime
hello trying to get this condition in a code

current line of code is plot signaldown = if warning then high else Double.NaN;
need it to be plot signaldown = if three warning(s) occur within 10bars then high else Double.NaN; any help thanks

replace this
def warning = ...
with your actual formula

if the boolean signal warning is true 3x, within 10 bars, then high and plot a down arrow.

Code:
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

plot signaldown = if warn then high else Double.NaN;
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#
 
Last edited:
Solution

Piper2808t

Member
2019 Donor
VIP
if the boolean signal warning is true 3x, within 10 bars, then high and plot a down arrow.

Code:
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

plot signaldown = if warn then high else Double.NaN;
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#
for some reason it is not working
 

Piper2808t

Member
2019 Donor
VIP
got it to work but is there a way to get a horizontal line at the first arrow down its plotting multiple arrows when the signal occurs looking for a horizontal line at the first arrow
 

halcyonguy

Well-known member
VIP
Lifetime
got it to work but is there a way to get a horizontal line at the first arrow down its plotting multiple arrows when the signal occurs looking for a horizontal line at the first arrow

try this one
added a line and a choice to show just the first arrow.

Code:
def na = double.nan;
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;

# add in your warning formula....
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

def linelevel = close;
def first_warn = if bn == 1 then 0
else if !warn[1] and warn then linelevel
else first_warn[1];

input show_first_line = yes;
plot z1 = if show_first_line then first_warn else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.light_gray);

input only_first_arrow = yes;
def warnz = if only_first_arrow then 
( !warn[1] and warn) else warn;

plot signaldown = if warnz then high else Double.NaN; 
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#
 

Piper2808t

Member
2019 Donor
VIP
try this one
added a line and a choice to show just the first arrow.

Code:
def na = double.nan;
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;

# add in your warning formula....
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

def linelevel = close;
def first_warn = if bn == 1 then 0
else if !warn[1] and warn then linelevel
else first_warn[1];

input show_first_line = yes;
plot z1 = if show_first_line then first_warn else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.light_gray);

input only_first_arrow = yes;
def warnz = if only_first_arrow then
( !warn[1] and warn) else warn;

plot signaldown = if warnz then high else Double.NaN;
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#
perfect thank you halcyonguy
try this one
added a line and a choice to show just the first arrow.

Code:
def na = double.nan;
def bn = barnumber();
input warn_qty = 3;
input bar_qty = 10;

# add in your warning formula....
def warning = ...

def warn = if bn <= bar_qty then 0 else
( sum(warning, bar_qty) >= warn_qty);

def linelevel = close;
def first_warn = if bn == 1 then 0
else if !warn[1] and warn then linelevel
else first_warn[1];

input show_first_line = yes;
plot z1 = if show_first_line then first_warn else na;
z1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
z1.SetDefaultColor(Color.light_gray);

input only_first_arrow = yes;
def warnz = if only_first_arrow then
( !warn[1] and warn) else warn;

plot signaldown = if warnz then high else Double.NaN;
signaldown.setpaintingStrategy(PaintingStrategy.ARROW_DOWN);
#
That is perfect thank you very much
 

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.
Top