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);
#
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
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
 
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
 
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);
#
 
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
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
431 Online
Create Post

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