2 out of 3 candle cross?

ninjatraderpro

New member
Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

Criteria:
--Using the 100 SMA plotted on a chart
--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

I've attached a couple screenshots to show what action I'm aiming for on the set-up.

Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".
 

Attachments

  • Screenshot 2023-12-23 at 10.34.57 AM.png
    Screenshot 2023-12-23 at 10.34.57 AM.png
    51 KB · Views: 81
  • Screenshot 2023-12-23 at 10.41.57 AM.jpg
    Screenshot 2023-12-23 at 10.41.57 AM.jpg
    35.7 KB · Views: 76
Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

Criteria:
--Using the 100 SMA plotted on a chart
--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

I've attached a couple screenshots to show what action I'm aiming for on the set-up.

Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".

if price crosses above the average, it could reset a counter, that looks for 2 closes above the average.

in pic2, the bars are red, green,red, green.
both red bars close below the line, so both red woud reset the count to 0.
the 3rd red bar is the 2nd close > ma , and so would trigger.

if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
after finding the 1st trigger, need a way to disable it from triggerig again and again.
 
Last edited:
if price crosses above the average, it could reset a counter, that looks for 2 closes above the average.

in pic2, the bars are red, green,red, green.
both red bars close below the line, so both red woud reset the count to 0.
the 3rd red bar is the 2nd close > ma , and so would trigger.

if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
after finding the 1st trigger, need a way to disable it from triggerig again and again.
Thanks for replying!!! I now see I should have been more clear: I meant 2 of 3 GREEN candles. Not just any candle color. If 2 of 3 (in any order) GREEN CANDLES close ABOVE the ma I would like to trigger an alert and also change the background color of my chart.
 
Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

Criteria:
--Using the 100 SMA plotted on a chart
--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

I've attached a couple screenshots to show what action I'm aiming for on the set-up.

Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".

i think this is what you are asking for


test upper study
pick quantity of signals to find within some total quantity (min , max)


Code:
#two_of_three_cond

#https://usethinkscript.com/threads/2-out-of-3-candle-cross.17529/
#2 out of 3 candle cross?
#ninjatraderpro  1/6

#Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

#GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

#Criteria:
#--Using the 100 SMA plotted on a chart
#--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
#--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

#I've attached a couple screenshots to show what action I'm aiming for on the set-up.

#Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".


#me
#if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
#after finding the 1st trigger, need a way to disable it from triggerig again and again.


def na = double.nan;
def bn = barnumber();
def data = close;

input min_qty = 2;
input max_qty = 3;

#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.Simple;
input avg1_length = 100;
def avg1 = MovingAverage(avg1_type, data, avg1_length );
input show_average_line = yes;
plot zavg1 = if show_average_line then avg1 else na;

def abovex = close > avg1;
def belowx = close < avg1;

def xupbn = if bn == 1 then 0
 else if (belowx[1] and abovex) then bn
 else xupbn[1];

def xdwnbn = if bn == 1 then 0
 else if (abovex[1] and belowx) then bn
 else xdwnbn[1];

def abovecnt = if bn == 1 then 0
 else if xupbn == bn then 1
 else if abovecnt[1] == min_qty then 0
 else if abovecnt[1] > 0 and abovex then abovecnt[1] + 1
 else abovecnt[1];

def belowcnt = if bn == 1 then 0
 else if xdwnbn == bn then 1
 else if belowcnt[1] == min_qty then 0
 else if belowcnt[1] > 0 and belowx then belowcnt[1] + 1
 else belowcnt[1];


def above_trigger = (bn - xupbn) <= max_qty and abovecnt >= min_qty ;
def below_trigger = (bn - xdwnbn) <= max_qty and belowcnt >= min_qty ;

plot zup = if above_trigger then low else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if below_trigger then high else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(3);
zdwn.hidebubble();

# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(above_trigger, "up" ,alert.BAR, sound.DING);
alert(below_trigger, "down" ,alert.BAR, sound.bell);

# crossing signals
input show_crossing_lines = no;
addverticalline(show_crossing_lines and xupbn == bn, "up", color.green);
addverticalline(show_crossing_lines and xdwnbn == bn, "down", color.red);

#addverticalline(above_trigger , "up", color.green);
#addverticalline(below_trigger, "down", color.red);
#


upper study and column study
8uViPW4.jpg


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

watchlist study

z2of3
http://tos.mx/!1OZ9tq71
1 hour

shows the quantity of bars since a trigger.
positive for up, negative for down

Code:
#z2of3
#two_of_three_cond

# chg upper - to count bars after a trigger and disaplay

#https://usethinkscript.com/threads/2-out-of-3-candle-cross.17529/
#2 out of 3 candle cross?
#ninjatraderpro  1/6

#Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

#GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

#Criteria:
#--Using the 100 SMA plotted on a chart
#--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
#--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

#I've attached a couple screenshots to show what action I'm aiming for on the set-up.

#Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".


#me
#if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
#after finding the 1st trigger, need a way to disable it from triggerig again and again.


def na = double.nan;
def bn = barnumber();
def data = close;

input min_qty = 2;
input max_qty = 3;

#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.Simple;
input avg1_length = 100;
def avg1 = MovingAverage(avg1_type, data, avg1_length );
input show_average_line = yes;
#plot zavg1 = if show_average_line then avg1 else na;

def abovex = close > avg1;
def belowx = close < avg1;

def xupbn = if bn == 1 then 0
 else if (belowx[1] and abovex) then bn
 else xupbn[1];

def xdwnbn = if bn == 1 then 0
 else if (abovex[1] and belowx) then bn
 else xdwnbn[1];

def abovecnt = if bn == 1 then 0
 else if xupbn == bn then 1
 else if abovecnt[1] == min_qty then 0
 else if abovecnt[1] > 0 and abovex then abovecnt[1] + 1
 else abovecnt[1];

def belowcnt = if bn == 1 then 0
 else if xdwnbn == bn then 1
 else if belowcnt[1] == min_qty then 0
 else if belowcnt[1] > 0 and belowx then belowcnt[1] + 1
 else belowcnt[1];


def above_trigger = (bn - xupbn) <= max_qty and abovecnt >= min_qty ;
def below_trigger = (bn - xdwnbn) <= max_qty and belowcnt >= min_qty ;

def abvcnt = if bn == 1 then 999
 else if above_trigger then 1
 else abvcnt[1] + 1;

def belcnt = if bn == 1 then 999
 else if below_trigger then 1
 else belcnt[1] + 1;

def cnt = if abvcnt < belcnt then abvcnt else -belcnt;

plot z = cnt;
z.setdefaultcolor(color.black);

assignbackgroundcolor(if cnt > 0 then color.green else color.red);

#plot z = above_trigger or below_trigger;

#plot zup = if above_trigger then low else na;
#zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#zup.SetDefaultColor(Color.green);
#zup.setlineweight(3);
#zup.hidebubble();

#plot zdwn = if below_trigger then high else na;
#zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdwn.SetDefaultColor(Color.red);
#zdwn.setlineweight(3);
#zdwn.hidebubble();

# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
#alert(above_trigger, "up" ,alert.BAR, sound.DING);
#alert(below_trigger, "down" ,alert.BAR, sound.bell);

# crossing signals
#input show_crossing_lines = no;
#addverticalline(show_crossing_lines and xupbn == bn, "up", color.green);
#addverticalline(show_crossing_lines and xdwnbn == bn, "down", color.red);

#addverticalline(above_trigger , "up", color.green);
#addverticalline(below_trigger, "down", color.red);
#
 
i think this is what you are asking for


test upper study
pick quantity of signals to find within some total quantity (min , max)


Code:
#two_of_three_cond

#https://usethinkscript.com/threads/2-out-of-3-candle-cross.17529/
#2 out of 3 candle cross?
#ninjatraderpro  1/6

#Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

#GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

#Criteria:
#--Using the 100 SMA plotted on a chart
#--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
#--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

#I've attached a couple screenshots to show what action I'm aiming for on the set-up.

#Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".


#me
#if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
#after finding the 1st trigger, need a way to disable it from triggerig again and again.


def na = double.nan;
def bn = barnumber();
def data = close;

input min_qty = 2;
input max_qty = 3;

#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.Simple;
input avg1_length = 100;
def avg1 = MovingAverage(avg1_type, data, avg1_length );
input show_average_line = yes;
plot zavg1 = if show_average_line then avg1 else na;

def abovex = close > avg1;
def belowx = close < avg1;

def xupbn = if bn == 1 then 0
 else if (belowx[1] and abovex) then bn
 else xupbn[1];

def xdwnbn = if bn == 1 then 0
 else if (abovex[1] and belowx) then bn
 else xdwnbn[1];

def abovecnt = if bn == 1 then 0
 else if xupbn == bn then 1
 else if abovecnt[1] == min_qty then 0
 else if abovecnt[1] > 0 and abovex then abovecnt[1] + 1
 else abovecnt[1];

def belowcnt = if bn == 1 then 0
 else if xdwnbn == bn then 1
 else if belowcnt[1] == min_qty then 0
 else if belowcnt[1] > 0 and belowx then belowcnt[1] + 1
 else belowcnt[1];


def above_trigger = (bn - xupbn) <= max_qty and abovecnt >= min_qty ;
def below_trigger = (bn - xdwnbn) <= max_qty and belowcnt >= min_qty ;

plot zup = if above_trigger then low else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if below_trigger then high else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(3);
zdwn.hidebubble();

# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert(above_trigger, "up" ,alert.BAR, sound.DING);
alert(below_trigger, "down" ,alert.BAR, sound.bell);

# crossing signals
input show_crossing_lines = no;
addverticalline(show_crossing_lines and xupbn == bn, "up", color.green);
addverticalline(show_crossing_lines and xdwnbn == bn, "down", color.red);

#addverticalline(above_trigger , "up", color.green);
#addverticalline(below_trigger, "down", color.red);
#


upper study and column study
8uViPW4.jpg


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

watchlist study

z2of3
http://tos.mx/!1OZ9tq71
1 hour

shows the quantity of bars since a trigger.
positive for up, negative for down

Code:
#z2of3
#two_of_three_cond

# chg upper - to count bars after a trigger and disaplay

#https://usethinkscript.com/threads/2-out-of-3-candle-cross.17529/
#2 out of 3 candle cross?
#ninjatraderpro  1/6

#Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

#GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

#Criteria:
#--Using the 100 SMA plotted on a chart
#--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
#--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

#I've attached a couple screenshots to show what action I'm aiming for on the set-up.

#Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".


#me
#if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
#after finding the 1st trigger, need a way to disable it from triggerig again and again.


def na = double.nan;
def bn = barnumber();
def data = close;

input min_qty = 2;
input max_qty = 3;

#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.Simple;
input avg1_length = 100;
def avg1 = MovingAverage(avg1_type, data, avg1_length );
input show_average_line = yes;
#plot zavg1 = if show_average_line then avg1 else na;

def abovex = close > avg1;
def belowx = close < avg1;

def xupbn = if bn == 1 then 0
 else if (belowx[1] and abovex) then bn
 else xupbn[1];

def xdwnbn = if bn == 1 then 0
 else if (abovex[1] and belowx) then bn
 else xdwnbn[1];

def abovecnt = if bn == 1 then 0
 else if xupbn == bn then 1
 else if abovecnt[1] == min_qty then 0
 else if abovecnt[1] > 0 and abovex then abovecnt[1] + 1
 else abovecnt[1];

def belowcnt = if bn == 1 then 0
 else if xdwnbn == bn then 1
 else if belowcnt[1] == min_qty then 0
 else if belowcnt[1] > 0 and belowx then belowcnt[1] + 1
 else belowcnt[1];


def above_trigger = (bn - xupbn) <= max_qty and abovecnt >= min_qty ;
def below_trigger = (bn - xdwnbn) <= max_qty and belowcnt >= min_qty ;

def abvcnt = if bn == 1 then 999
 else if above_trigger then 1
 else abvcnt[1] + 1;

def belcnt = if bn == 1 then 999
 else if below_trigger then 1
 else belcnt[1] + 1;

def cnt = if abvcnt < belcnt then abvcnt else -belcnt;

plot z = cnt;
z.setdefaultcolor(color.black);

assignbackgroundcolor(if cnt > 0 then color.green else color.red);

#plot z = above_trigger or below_trigger;

#plot zup = if above_trigger then low else na;
#zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#zup.SetDefaultColor(Color.green);
#zup.setlineweight(3);
#zup.hidebubble();

#plot zdwn = if below_trigger then high else na;
#zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdwn.SetDefaultColor(Color.red);
#zdwn.setlineweight(3);
#zdwn.hidebubble();

# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
#alert(above_trigger, "up" ,alert.BAR, sound.DING);
#alert(below_trigger, "down" ,alert.BAR, sound.bell);

# crossing signals
#input show_crossing_lines = no;
#addverticalline(show_crossing_lines and xupbn == bn, "up", color.green);
#addverticalline(show_crossing_lines and xdwnbn == bn, "down", color.red);

#addverticalline(above_trigger , "up", color.green);
#addverticalline(below_trigger, "down", color.red);
#
Halcyonguy thank you so much for your CLEAR expertise...you know what you're doing!!! Love it!! So I've been testing this out...and one thing I need to see if you can "tweak" is the sound alert timing. The sound overall is awesome...but the sound goes off when it "crosses" and not "closes"...and it therefore gives a bunch of false signals that end up going the opposite direction. It's all about the "close". So grateful for your help!! Also, is there anyway you can have it also change the background of my chart so I get a "sound upon close" and a background color change simultaneously? When it crosses above that moving average, it changes to a color and when it crosses below the moving average its the normal default color?
 
Halcyonguy thank you so much for your CLEAR expertise...you know what you're doing!!! Love it!! So I've been testing this out...and one thing I need to see if you can "tweak" is the sound alert timing. The sound overall is awesome...but the sound goes off when it "crosses" and not "closes"...and it therefore gives a bunch of false signals that end up going the opposite direction. It's all about the "close". So grateful for your help!! Also, is there anyway you can have it also change the background of my chart so I get a "sound upon close" and a background color change simultaneously? When it crosses above that moving average, it changes to a color and when it crosses below the moving average its the normal default color?

here is an updated upper chart study,
changed alerts to sound on bar after the trigger
add screen color change on bar after the trigger

Code:
#two_of_three_cond

#https://usethinkscript.com/threads/2-out-of-3-candle-cross.17529/
#2 out of 3 candle cross?
#ninjatraderpro  1/6

#Hello all. This is my first time joining this great community. I'm not a coder but am learning ThinkScript little by little...but am still BRAND NEW. Here's what I'm looking to do:

#GOAL: I would like to have an ALERT go off and even a pop up (if that's even possible in TOS) when the following criteria are met on a SPECIFIC WATCH LIST. If a watchlist assigment is not possible, then I could have 10-20 charts up and that could do the trick too.

#Criteria:
#--Using the 100 SMA plotted on a chart
#--I would like that alert to happen when 2 of 3 candles (in any given order...red, green green...green, red, green...green green red) officially CLOSE above the 100 after coming from BELOW the 100
#--I would like to have the ability to change the inputs in the study as well (sma, time frame, based on OPEN, CLOSE, OR MARK)

#I've attached a couple screenshots to show what action I'm aiming for on the set-up.

#Thank you ahead of time and if I'm asking for too much, just tell me "dude...that's not how this community works".


#me
#if you want to count after the 1st crossing, then we have to define how many previous bars have to be below the ma. also have to define when to cancel. what if it crosses above the ma, then crosses below and drops , and stays below for 40 bars.
#after finding the 1st trigger, need a way to disable it from triggerig again and again.


def na = double.nan;
def bn = barnumber();
def data = close;

input min_qty = 2;
input max_qty = 3;

addlabel(1,
("find " + min_qty + " out of " + max_qty + " bars that close above/below avg")
, color.yellow);


#input avg1_type = AverageType.exponential;
input avg1_type = AverageType.Simple;
input avg1_length = 100;
def avg1 = MovingAverage(avg1_type, data, avg1_length );
input show_average_line = yes;
plot zavg1 = if show_average_line then avg1 else na;

def abovex = close > avg1;
def belowx = close < avg1;

def xupbn = if bn == 1 then 0
 else if (belowx[1] and abovex) then bn
 else xupbn[1];

def xdwnbn = if bn == 1 then 0
 else if (abovex[1] and belowx) then bn
 else xdwnbn[1];

def abovecnt = if bn == 1 then 0
 else if xupbn == bn then 1
 else if abovecnt[1] == min_qty then 0
 else if abovecnt[1] > 0 and abovex then abovecnt[1] + 1
 else abovecnt[1];

def belowcnt = if bn == 1 then 0
 else if xdwnbn == bn then 1
 else if belowcnt[1] == min_qty then 0
 else if belowcnt[1] > 0 and belowx then belowcnt[1] + 1
 else belowcnt[1];


def above_trigger = (bn - xupbn) <= max_qty and abovecnt >= min_qty ;
def below_trigger = (bn - xdwnbn) <= max_qty and belowcnt >= min_qty ;

plot zup = if above_trigger then low else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if below_trigger then high else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(3);
zdwn.hidebubble();

# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
#alert(above_trigger, "up" ,alert.BAR, sound.DING);
#alert(below_trigger, "down" ,alert.BAR, sound.bell);
# add offset to trigger, to delay until bar is closed
alert(above_trigger[1], "up" ,alert.BAR, sound.DING);
alert(below_trigger[1], "down" ,alert.BAR, sound.bell);

assignbackgroundcolor(if above_trigger[1] then color.green else if below_trigger[1] then color.red else color.current);

# crossing signals
input show_crossing_lines = no;
addverticalline(show_crossing_lines and xupbn == bn, "up", color.green);
addverticalline(show_crossing_lines and xdwnbn == bn, "down", color.red);
#addverticalline(above_trigger , "up", color.green);
#addverticalline(below_trigger, "down", color.red);
#
 

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