I know many users on this platform use base breakouts, it be flag, flat base, cup with handle, double bottom etc.
the one key metric to most of these breakouts is volume increase while pushing through Resistance or pivot level,
I like to use a 3 moving average stack on the hourly chart (@halcyonguy wrote a really nice indicator for this. Find when 2 to 5 averages are close together, within x%.)
after I have found the base on a daily and or weekly chart! I look for 10 EMA. 20 EMA and 50 SMA to all be within 1.5% of each other, drying volume to at least 30% less than the 50 day average volume to indicate a possible breakout coming! then that name gets put on watch list and we wait for the volume surge and price expansion! is there any way to write an alert for when the 3 moving averages are converged within 1.5% of each other or write a watch column code along with the volume condition being at least 30% less than 50-day average? and is it possible to write a strategy that breakouts after all conditions have been met? volume at 1030am being X% above the 50 day average volume on breakout day is something I have found hard to identify, usually cant see that information clearly until market close!
thank you for all the great work everyone here does, it takes a special talent to write these codes, you all are amazing!
I know many users on this platform use base breakouts, it be flag, flat base, cup with handle, double bottom etc.
the one key metric to most of these breakouts is volume increase while pushing through Resistance or pivot level,
I like to use a 3 moving average stack on the hourly chart (@halcyonguy wrote a really nice indicator for this. Find when 2 to 5 averages are close together, within x%.)
after I have found the base on a daily and or weekly chart! I look for 10 EMA. 20 EMA and 50 SMA to all be within 1.5% of each other, drying volume to at least 30% less than the 50 day average volume to indicate a possible breakout coming! then that name gets put on watch list and we wait for the volume surge and price expansion! is there any way to write an alert for when the 3 moving averages are converged within 1.5% of each other or write a watch column code along with the volume condition being at least 30% less than 50-day average? and is it possible to write a strategy that breakouts after all conditions have been met? volume at 1030am being X% above the 50 day average volume on breakout day is something I have found hard to identify, usually cant see that information clearly until market close!
thank you for all the great work everyone here does, it takes a special talent to write these codes, you all are amazing!
you are asking a question. you are asking for a study to be made.
you don't have a finished study. this post belongs in the questions section. @MerryDay
you typed a lot of words, asking for several things. your words are all over the place, in what and where you want to see something.
best to add a summary at the end, short concise statements,
there are everal things that need to be clarified,
chart , scan ??
..find a base on a daily and or weekly chart ? no idea what this is
..EMA10 and EMA20 and SMA50 are within 1.5% of each other
..drying volume to at least 30% less than the 50 day average volume ? drying ?
....if comparing volume during the current day, to a daily average, it will always be lower.
....might have to compare a proportion, based on hours that have past in current day.
......when 2 hours have past, 2/6.5 of a day, (current volume < ((2/6.5 * average)*0.7))
..you want to check volume only at a specific time ?
watch list
..symbols from scan
..volume surge ? what defines this
..price expansion ? what defines this
alert ? an alert in the chart study?
..when the 3 moving averages are within 1.5% of each other
Thank you for letting me know, I didnt clarify very well (sometimes the mind is racing around, and we type out words as we think about them and not realize the sentences are as clear as our thoughts, I apologize for that)
1) Is it possible to make a watch list column to identify when the 3 moving averages are with 1.5% of each other?
2) can we make a strategy, price crosses above resistance or pivot with a volume surge of above 100% of 50-day average volume (possibly using projection pivots written by @Mobius for the pivot / resistance)
3) alert when three moving averages are within 1.5% of each other and volume on X candle is at least 30'% less than the 60 bar average on the hourly chart
Thank you for letting me know, I didnt clarify very well (sometimes the mind is racing around, and we type out words as we think about them and not realize the sentences are as clear as our thoughts, I apologize for that)
1) Is it possible to make a watch list column to identify when the 3 moving averages are with 1.5% of each other?
2) can we make a strategy, price crosses above resistance or pivot with a volume surge of above 100% of 50-day average volume (possibly using projection pivots written by @Mobius for the pivot / resistance)
3) alert when three moving averages are within 1.5% of each other and volume on X candle is at least 30'% less than the 60 bar average on the hourly chart
Just a note for new traders, this indicator is very useful and can be very powerful when used right, it can also be the death of a trader if not used properly. just because the 3 lines are together does not mean it is a buy or sell.
Rules I use.
1) I like to see price undercut all three averages then snap back and close above (sometimes the shorter time frames slightly undercut the 50 MA and then cross back above)
2) price must move away from moving averages on increased volume, for me I like to see at least +50% of 50-day average volume by 11am
3)I like to see MACD crossed up or crossing up while below the zero line (this for me is ideal, but any cross is ok)
4) low risk entry. stops are placed just below moving averages, we try to keep stops no more than 3%
I like this indicator, is there a way to set it up that the chart only is clear when all 3 ema's are stacked correctly, and not clear when they are not?
@halcyonguy this indicator is about as best of indicator for I want it for as I have seen. Thank you again for writing this code! I was playin around with it trying to create it into a strategy but im not having any luck, im probably not going to be able write it as it should be,
is there a way to turn this into a strat by saying after Price and both the 10 and 20 exponentials undercut the 50 simple and price comes back to close above the 50 simple an to show a pilot buy and when the 10 and 20 cross back above to show an add buy and any sort of combo?
just and added thought, I usually place my stops right below the 50 SMA and set a 1st target @ 10%, Ill close order when price closes below the 10 EMA if it doesnt reach y first target!
@halcyonguy this indicator is about as best of indicator for I want it for as I have seen. Thank you again for writing this code! I was playin around with it trying to create it into a strategy but im not having any luck, im probably not going to be able write it as it should be,
is there a way to turn this into a strat by saying after Price and both the 10 and 20 exponentials undercut the 50 simple and price comes back to close above the 50 simple an to show a pilot buy and when the 10 and 20 cross back above to show an add buy and any sort of combo?
just and added thought, I usually place my stops right below the 50 SMA and set a 1st target @ 10%, Ill close order when price closes below the 10 EMA if it doesnt reach y first target!
that is a really long sentence. it seems like you want to look for a sequence of events. this can usually be done, but can have feedback issues.
it will become easier to understand if we can clarify each condition, by rewording each one into short statements.
i copied your sentence and separated it into several statements. let's try to rewrite it to describe exactly what has to happen. some may seem like nitpicking, but are intended to get you to think in exact correct terms.
turn this into a strat,
1..after Price
after price does what?
close, high, low,...?
2..and both the 10 and 20 exponentials undercut the 50 simple
what does undercut mean?
crosses below ?
is lower than?
3.. and price comes back to close above the 50 simple
price? close or high or low or....
close? if during the bar, close later moves lower, the signal will disappear.
high? a signal will stay
---- when to give up on waiting for it to happen, and cancel? after 5 bars, 20, 100? some price movement?
4... and to show a pilot buy
no idea what a pilot buy is
5.. and when the 10 and 20 cross back above
above what?
6.. to show an add buy and any sort of combo?
addorder buy?
what is a combo?
If you are going to have conditions to start a trade then you need to come up with conditions that will stop it.
What needs to happen for the trade to close when making money?
What has to happen to abort the trade if it's losing?
i see you edited the post and added your ideas on stops.
I definitely do not know how to make the logic for writing codes lol.
Let me start by saying, there are a few variations this can be traded from. but to try to simplify.
1) after prices crosses below 50 SMA, then trades back above the 50 SMA I will usually initiate a pilot buy!
2) the 10 and 20 EMA will usually follow close behind price and cross below or come very close to the 50 SMA. for the sake of strategy lets say the two averages cross below as well, then when they both cross back above the 50SMA I will add my position.
3) I usually place stops slightly under the 50 SMA (I try to keep stops around 3%)
all buys will need to see that all the moving averages are within the 1.5% of each other at the time of buy. otherwise, the above mentioned are not valid.
I have been trying to upload a photo and having a lot of trouble trying to insert a photo with examples, copy and paste of the link below seem to work for me, maybe this will paint a clearer picture of what im trying to accomplish. this will give me a much better back test result and also, hopefully help me semi automate my trades!
I have been trying to upload a photo and having a lot of trouble trying to insert a photo with examples, copy and paste of the link below seem to work for me, maybe this will paint a clearer picture of what im trying to accomplish. this will give me a much better back test result and also, hopefully help me semi automate my trades!
I definitely do not know how to make the logic for writing codes lol.
Let me start by saying, there are a few variations this can be traded from. but to try to simplify.
1) after prices crosses below 50 SMA, then trades back above the 50 SMA I will usually initiate a pilot buy!
2) the 10 and 20 EMA will usually follow close behind price and cross below or come very close to the 50 SMA. for the sake of strategy lets say the two averages cross below as well, then when they both cross back above the 50SMA I will add my position.
3) I usually place stops slightly under the 50 SMA (I try to keep stops around 3%)
all buys will need to see that all the moving averages are within the 1.5% of each other at the time of buy. otherwise, the above mentioned are not valid.
made from rules in post10
show arrows for buying , when an a signal crosses another
..check if the price range of 3 averages are within a x% price range.
..when close crosses above ma50 and 3 averages are close together , pilot buy
....draw a green arrow
....draw a green buy line from close
....draw a purple stop line from low
....draw cyan lines, at 1 bar wide, above and below the bar, to represent the price range of the near %. (centered over the 3 averages)
..when other 2 averages cross above the ma50 , buy more
....draw a cyan arrow
....draw a light green buy line from close
....draw a orange stop line from low
i made the stop lines at the low of the buy bar.
Code:
# avgs_near_crossings_00b
#https://usethinkscript.com/threads/find-when-3-averages-are-close-together.14615/#post-121359
#Break Trader 3/7 #10
# rewrite rules
#1) buys need to occur during all the moving averages are within the 1.5% of each other
#2) close crosses above 50 SMA > pilot buy
#3) the ema10 and ema20 , when they both cross back above the 50SMA I will add my position.
#4) place stops slightly under the 50 SMA (I try to keep stops around 3%)
#----------------------------
def na = double.nan;
def bn = barnumber();
# 10 EMA. 20 EMA and 50 SMA are within 1.5%
input averages_near_percent = 1.5;
#input averages_near_percent = 0.3;
def price = close;
input ma1_len = 10;
input ma1_type = AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);
input ma2_len = 20;
input ma2_type = AverageType.EXPONENTIAL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);
input ma3_len = 50;
input ma3_type = AverageType.simple;
def ma3 = MovingAverage(ma3_type, price, ma3_len);
input show_lines = yes;
plot z1 = if show_lines then ma1 else na;
z1.setdefaultcolor(getcolor(1));
#z1.setlineweight(1);
z1.hidebubble();
plot z2 = if show_lines then ma2 else na;
z2.setdefaultcolor(getcolor(2));
#z2.setlineweight(1);
z2.hidebubble();
plot z3 = if show_lines then ma3 else na;
z3.setdefaultcolor(getcolor(3));
#z3.setlineweight(1);
z3.hidebubble();
# find max and min avg
def avgmax = max(ma1, max(ma2,ma3));
def avgmin = min(ma1, min(ma2,ma3));
def avgrngper = round(100*(avgmax-avgmin)/avgmin, 1);
# calc x% dollar range, based on % of lower price.
def avgs_rng = avgmin * (averages_near_percent / 100);
def avgs_mid = (avgmax + avgmin)/2;
input show_labels = yes;
addlabel(show_labels, " " , color.black);
addlabel(show_labels, "near percent " + aspercent(averages_near_percent /100) , color.yellow);
addlabel(show_labels, "near %, dollar range " + asdollars(avgs_rng) , color.yellow);
#================================
# rules
#1) buys need to occur during all the moving averages are within the 1.5% of each other
def nearavgs = (avgrngper <= averages_near_percent);
#2) pilot buy = close crosses above 50 SMA
# option - wait on buy until ema10 and ema20 are below ma50 ?
def pilot_buy = close crosses above ma3;
def pilot_cancel = close crosses below ma3;
#3) the ema10 and ema20 , when they both cross back above the 50SMA I will add my position.
def ema10_xup = ma1 crosses above ma3;
def ema20_xup = ma2 crosses above ma3;
def ema10_xdwn = ma1 crosses below ma3;
def ema20_xdwn = ma2 crosses below ma3;
def avg12 = if (ema10_xdwn or ema20_xdwn) then 0
else if avg12[1] == 0 and (ema10_xup or ema20_xup) then 1
else if avg12[1] == 1 and (ema10_xup or ema20_xup) then 2
else avg12[1];
def ema1020xup = (!avg12[1] and avg12);
#4) place stops slightly under the 50 SMA (I try to keep stops around 3%)
# set stop lines at the low of the buy bar
#----------------------------------------
# pilot buy - stuff
# pilot buy - arrow
def buy1 = (nearavgs and pilot_buy);
plot z5 = if buy1 then low*0.999 else na;
z5.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z5.SetDefaultColor(Color.green);
z5.setlineweight(3);
z5.hidebubble();
#---------
# draw lines representing % price zone , above and below , centered on min and max avg lines
# cyan horz lines , 1 bar wide, during a pilot buy bar
# represents the price range of the near percent
input show_lines_for_percent_range = yes;
plot zb1top = if show_lines_for_percent_range and buy1 then (avgs_mid + (avgs_rng / 2)) else na;
zb1top.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zb1top.SetDefaultColor(Color.cyan);
zb1top.setlineweight(2);
zb1top.hidebubble();
plot zb1bot = if show_lines_for_percent_range and buy1 then (avgs_mid - (avgs_rng / 2)) else na;
zb1bot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zb1bot.SetDefaultColor(Color.cyan);
zb1bot.setlineweight(2);
zb1bot.hidebubble();
#---------
# buy line from pilot buy
def pilot_buy_line =
if pilot_cancel then na
else if pilot_buy then close
else pilot_buy_line[1];
plot z6b = pilot_buy_line;
z6b.SetDefaultColor(Color.green);
#---------
# stop line from pilot buy
def pilot_stop_line =
if pilot_cancel then na
else if pilot_buy then low
else pilot_stop_line[1];
plot z6 = pilot_stop_line;
z6.SetDefaultColor(Color.magenta);
#---------------------------
# buy more
# ema10 and ema20 croseed above
# arrow
def buymore = (nearavgs and ema1020xup);
plot z7 = if buymore then low*0.999 else na;
z7.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z7.SetDefaultColor(Color.cyan);
z7.setlineweight(3);
z7.hidebubble();
#---------
# stop line from buy more
def buymore_stop_line =
if (ema10_xdwn or ema20_xdwn) then na
else if ema1020xup then low
else buymore_stop_line[1];
plot z8 = buymore_stop_line;
z8.SetDefaultColor(Color.orange);
#---------
# buy line from buy more
def buymore_buy_line =
if (ema10_xdwn or ema20_xdwn) then na
else if ema1020xup then close
else buymore_buy_line[1];
plot z9 = buymore_buy_line;
z9.SetDefaultColor(Color.light_green);
#---------------------------
#
made from rules in post10
show arrows for buying , when an a signal crosses another
..check if the price range of 3 averages are within a x% price range.
..when close crosses above ma50 and 3 averages are close together , pilot buy
....draw a green arrow
....draw a green buy line from close
....draw a purple stop line from low
....draw cyan lines, at 1 bar wide, above and below the bar, to represent the price range of the near %. (centered over the 3 averages)
..when other 2 averages cross above the ma50 , buy more
....draw a cyan arrow
....draw a light green buy line from close
....draw a orange stop line from low
i made the stop lines at the low of the buy bar.
Code:
# avgs_near_crossings_00b
#https://usethinkscript.com/threads/find-when-3-averages-are-close-together.14615/#post-121359
#Break Trader 3/7 #10
# rewrite rules
#1) buys need to occur during all the moving averages are within the 1.5% of each other
#2) close crosses above 50 SMA > pilot buy
#3) the ema10 and ema20 , when they both cross back above the 50SMA I will add my position.
#4) place stops slightly under the 50 SMA (I try to keep stops around 3%)
#----------------------------
def na = double.nan;
def bn = barnumber();
# 10 EMA. 20 EMA and 50 SMA are within 1.5%
input averages_near_percent = 1.5;
#input averages_near_percent = 0.3;
def price = close;
input ma1_len = 10;
input ma1_type = AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);
input ma2_len = 20;
input ma2_type = AverageType.EXPONENTIAL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);
input ma3_len = 50;
input ma3_type = AverageType.simple;
def ma3 = MovingAverage(ma3_type, price, ma3_len);
input show_lines = yes;
plot z1 = if show_lines then ma1 else na;
z1.setdefaultcolor(getcolor(1));
#z1.setlineweight(1);
z1.hidebubble();
plot z2 = if show_lines then ma2 else na;
z2.setdefaultcolor(getcolor(2));
#z2.setlineweight(1);
z2.hidebubble();
plot z3 = if show_lines then ma3 else na;
z3.setdefaultcolor(getcolor(3));
#z3.setlineweight(1);
z3.hidebubble();
# find max and min avg
def avgmax = max(ma1, max(ma2,ma3));
def avgmin = min(ma1, min(ma2,ma3));
def avgrngper = round(100*(avgmax-avgmin)/avgmin, 1);
# calc x% dollar range, based on % of lower price.
def avgs_rng = avgmin * (averages_near_percent / 100);
def avgs_mid = (avgmax + avgmin)/2;
input show_labels = yes;
addlabel(show_labels, " " , color.black);
addlabel(show_labels, "near percent " + aspercent(averages_near_percent /100) , color.yellow);
addlabel(show_labels, "near %, dollar range " + asdollars(avgs_rng) , color.yellow);
#================================
# rules
#1) buys need to occur during all the moving averages are within the 1.5% of each other
def nearavgs = (avgrngper <= averages_near_percent);
#2) pilot buy = close crosses above 50 SMA
# option - wait on buy until ema10 and ema20 are below ma50 ?
def pilot_buy = close crosses above ma3;
def pilot_cancel = close crosses below ma3;
#3) the ema10 and ema20 , when they both cross back above the 50SMA I will add my position.
def ema10_xup = ma1 crosses above ma3;
def ema20_xup = ma2 crosses above ma3;
def ema10_xdwn = ma1 crosses below ma3;
def ema20_xdwn = ma2 crosses below ma3;
def avg12 = if (ema10_xdwn or ema20_xdwn) then 0
else if avg12[1] == 0 and (ema10_xup or ema20_xup) then 1
else if avg12[1] == 1 and (ema10_xup or ema20_xup) then 2
else avg12[1];
def ema1020xup = (!avg12[1] and avg12);
#4) place stops slightly under the 50 SMA (I try to keep stops around 3%)
# set stop lines at the low of the buy bar
#----------------------------------------
# pilot buy - stuff
# pilot buy - arrow
def buy1 = (nearavgs and pilot_buy);
plot z5 = if buy1 then low*0.999 else na;
z5.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z5.SetDefaultColor(Color.green);
z5.setlineweight(3);
z5.hidebubble();
#---------
# draw lines representing % price zone , above and below , centered on min and max avg lines
# cyan horz lines , 1 bar wide, during a pilot buy bar
# represents the price range of the near percent
input show_lines_for_percent_range = yes;
plot zb1top = if show_lines_for_percent_range and buy1 then (avgs_mid + (avgs_rng / 2)) else na;
zb1top.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zb1top.SetDefaultColor(Color.cyan);
zb1top.setlineweight(2);
zb1top.hidebubble();
plot zb1bot = if show_lines_for_percent_range and buy1 then (avgs_mid - (avgs_rng / 2)) else na;
zb1bot.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zb1bot.SetDefaultColor(Color.cyan);
zb1bot.setlineweight(2);
zb1bot.hidebubble();
#---------
# buy line from pilot buy
def pilot_buy_line =
if pilot_cancel then na
else if pilot_buy then close
else pilot_buy_line[1];
plot z6b = pilot_buy_line;
z6b.SetDefaultColor(Color.green);
#---------
# stop line from pilot buy
def pilot_stop_line =
if pilot_cancel then na
else if pilot_buy then low
else pilot_stop_line[1];
plot z6 = pilot_stop_line;
z6.SetDefaultColor(Color.magenta);
#---------------------------
# buy more
# ema10 and ema20 croseed above
# arrow
def buymore = (nearavgs and ema1020xup);
plot z7 = if buymore then low*0.999 else na;
z7.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
z7.SetDefaultColor(Color.cyan);
z7.setlineweight(3);
z7.hidebubble();
#---------
# stop line from buy more
def buymore_stop_line =
if (ema10_xdwn or ema20_xdwn) then na
else if ema1020xup then low
else buymore_stop_line[1];
plot z8 = buymore_stop_line;
z8.SetDefaultColor(Color.orange);
#---------
# buy line from buy more
def buymore_buy_line =
if (ema10_xdwn or ema20_xdwn) then na
else if ema1020xup then close
else buymore_buy_line[1];
plot z9 = buymore_buy_line;
z9.SetDefaultColor(Color.light_green);
#---------------------------
#
@halcyonguy you must be able to write this stuff in your sleep, I know there a lot of really good coders on here, I know many of them probably work on this stuff night and day. all I can say, I cant wait to load it and make her work! A thank you a bunch for everything you do on here.
@halcyonguy you must be able to write this stuff in your sleep, I know there a lot of really good coders on here, I know many of them probably work on this stuff night and day. all I can say, I cant wait to load it and make her work! A thank you a bunch for everything you do on here.
thank you, and you're welcome.
i have written enough studies that i have many functions memorized and usually have an idea what i want to do ( when creating a study).
@halcyonguy, maybe you remember writing this code? this code has been working very well for me, thank you again for such awesome work, I have a question or two, due the fact that I run a business and cant search charts most days, I am wondering if it is possible to create a watch list label that turns green when the 3 averages are within that 1.5% of each other, a much easier and quicker way to locate the setups.
Also, is it possible to create a watch list buy label for the watch list, only for the candle, or within 1 or two candles the buy has been trigger?
Thank you
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.
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.