How to plot HIGH/LOW of recent monthly EMA crossover

grey

New member
Im new to thinkscript, I've been trying too look for existing script but can't find any. basically i just need to plot horizontal line for the high and low of MONTHLY EMA 4 crossover EMA 8 candle.

Thank you.

something that looks like this:
 
Last edited:
I'm not sure what you're asking exactly, you may want to explain it more clearly or in more detail.

For example; what is supposed to be crossing what? The EMA's cross each other? One candle crosses both EMA's?

What do you mean by highest high and lowest low? Highest and lowest relative to what? Do you just mean the candle's high and low?
 
I'm not sure what you're asking exactly, you may want to explain it more clearly or in more detail.

For example; what is supposed to be crossing what? The EMA's cross each other? One candle crosses both EMA's?

What do you mean by highest high and lowest low? Highest and lowest relative to what? Do you just mean the candle's high and low?
yes just the plot of high and the low of the ema crossover candle. like the one on the image with arrow up on the bottom candle is the most recent ema4 crossover ema8 on monthly aggregation period.
 
Last edited:
Im new to thinkscript, I've been trying too look for existing script but can't find any. basically i just need to plot horizontal line for the high and low of MONTHLY EMA 4 crossover EMA 8 candle.

Thank you.

something that looks like this:

this would have been alot easier to understand if you would have said,
i'd like horizontal lines , based on the candles identified by the
TD movingavgcrossover study.

showing a chart picture with unrelated lines on it, made it even more confusing.

i stared at the image and read the study names and the symbol, and guessed that you wanted lines drawn from the high and low, of candles identified by arrows from that crossover study.

your chart image shows
negg 10y month
movingavgcrossover( 4,8, ema, ema, below)
and a 2nd study with ( .... , above)

i copied the TD study and added code to draw lines and changed how it draws arrows ( so 1 study will draw both up and down arrows)

can choose to
...turn off the 2 average lines
...turn off up arrows or down arrows, and their horizontal lines

Ruby:
# movingavgcrossover02

# add horz lines from candle with up arrow and down arrow
# change arrow code , to show both up and down with 1 study

# movingavgcrossover
# TD Ameritrade IP Company, Inc. (c) 2009-2021

input price = close;
input length1 = 4;
input length2 = 8;
input averageType1 = AverageType.exponential;
input averageType2 = AverageType.exponential;
#input crossingType = {default above, below};

input show_cross_up_lines = yes;
input show_cross_down_lines = yes;

input show_average_lines = yes;

def avg1 = MovingAverage(averageType1, price, length1);
def avg2 = MovingAverage(averageType2, price, length2);

def na = double.nan;
plot line1 = if show_average_lines then avg1 else na;
plot line2 = if show_average_lines then avg2 else na;
line1.setdefaultcolor(color.yellow);
line2.setdefaultcolor(color.cyan);

def crossup = avg1 crosses above avg2;
def crossdwn = avg1 crosses below avg2;

#plot signal = crosses(avg1, avg2, crossingType == CrossingType.above);
#signal.DefineColor("Above", color.green);
#signal.DefineColor("Below", color.magenta);
#signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));
#signal.SetPaintingStrategy(if crossingType == CrossingType.above
#    then PaintingStrategy.BOOLEAN_ARROW_UP
#    else PaintingStrategy.BOOLEAN_ARROW_DOWN);


plot xup = if show_cross_up_lines then crossup else na;
plot xdwn = if show_cross_down_lines then crossdwn else na;
xup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
xdwn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
xup.setdefaultColor(color.green);
xdwn.setdefaultColor(color.magenta);
xup.setlineweight(3);
xdwn.setlineweight(3);

# add horz lines from candle with up arrow and down arrow
def uphi = if (show_cross_up_lines and (avg1 crosses above avg2)) then high else uphi[1];
def uplo = if (show_cross_up_lines and (avg1 crosses above avg2)) then low else uplo[1];

def dwnhi = if (show_cross_down_lines and (avg1 crosses below avg2)) then high else dwnhi[1];
def dwnlo = if (show_cross_down_lines and (avg1 crosses below avg2)) then low else dwnlo[1];

plot uph = uphi;
plot upl = uplo;
plot dwnh = dwnhi;
plot dwnl = dwnlo;
uph.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
upl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dwnh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dwnl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
uph.setdefaultColor(color.green);
upl.setdefaultColor(color.blue);
dwnh.setdefaultColor(color.magenta);
dwnl.setdefaultColor(color.red);
#

jbSE8pD.jpg
 
a side note,
the TD movingavgcrossover study uses 1 plot to draw 1 of 2 objects with different colors.
it has an if then to decide which arrow (paintingstrategy) to plot, an up arrow or a down arrow.
i have rarely seen this, so thought i would mention it. this method might be able to simplify a study for someone.
i didn't take the time to modify the original , so both arrows would plot. i just commented them out and added 2 separate plots to display them.

#signal.SetPaintingStrategy(if crossingType == CrossingType.above
# then PaintingStrategy.BOOLEAN_ARROW_UP
# else PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
this would have been alot easier to understand if you would have said,
i'd like horizontal lines , based on the candles identified by the
TD movingavgcrossover study.

showing a chart picture with unrelated lines on it, made it even more confusing.

i stared at the image and read the study names and the symbol, and guessed that you wanted lines drawn from the high and low, of candles identified by arrows from that crossover study.

your chart image shows
negg 10y month
movingavgcrossover( 4,8, ema, ema, below)
and a 2nd study with ( .... , above)

i copied the TD study and added code to draw lines and changed how it draws arrows ( so 1 study will draw both up and down arrows)

can choose to
...turn off the 2 average lines
...turn off up arrows or down arrows, and their horizontal lines

Ruby:
# movingavgcrossover02

# add horz lines from candle with up arrow and down arrow
# change arrow code , to show both up and down with 1 study

# movingavgcrossover
# TD Ameritrade IP Company, Inc. (c) 2009-2021

input price = close;
input length1 = 4;
input length2 = 8;
input averageType1 = AverageType.exponential;
input averageType2 = AverageType.exponential;
#input crossingType = {default above, below};

input show_cross_up_lines = yes;
input show_cross_down_lines = yes;

input show_average_lines = yes;

def avg1 = MovingAverage(averageType1, price, length1);
def avg2 = MovingAverage(averageType2, price, length2);

def na = double.nan;
plot line1 = if show_average_lines then avg1 else na;
plot line2 = if show_average_lines then avg2 else na;
line1.setdefaultcolor(color.yellow);
line2.setdefaultcolor(color.cyan);

def crossup = avg1 crosses above avg2;
def crossdwn = avg1 crosses below avg2;

#plot signal = crosses(avg1, avg2, crossingType == CrossingType.above);
#signal.DefineColor("Above", color.green);
#signal.DefineColor("Below", color.magenta);
#signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));
#signal.SetPaintingStrategy(if crossingType == CrossingType.above
#    then PaintingStrategy.BOOLEAN_ARROW_UP
#    else PaintingStrategy.BOOLEAN_ARROW_DOWN);


plot xup = if show_cross_up_lines then crossup else na;
plot xdwn = if show_cross_down_lines then crossdwn else na;
xup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
xdwn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
xup.setdefaultColor(color.green);
xdwn.setdefaultColor(color.magenta);
xup.setlineweight(3);
xdwn.setlineweight(3);

# add horz lines from candle with up arrow and down arrow
def uphi = if (show_cross_up_lines and (avg1 crosses above avg2)) then high else uphi[1];
def uplo = if (show_cross_up_lines and (avg1 crosses above avg2)) then low else uplo[1];

def dwnhi = if (show_cross_down_lines and (avg1 crosses below avg2)) then high else dwnhi[1];
def dwnlo = if (show_cross_down_lines and (avg1 crosses below avg2)) then low else dwnlo[1];

plot uph = uphi;
plot upl = uplo;
plot dwnh = dwnhi;
plot dwnl = dwnlo;
uph.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
upl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dwnh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
dwnl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
uph.setdefaultColor(color.green);
upl.setdefaultColor(color.blue);
dwnh.setdefaultColor(color.magenta);
dwnl.setdefaultColor(color.red);
#

jbSE8pD.jpg
thank you, man! this is the one im looking for.
 
a side note,
the TD movingavgcrossover study uses 1 plot to draw 1 of 2 objects with different colors.
it has an if then to decide which arrow (paintingstrategy) to plot, an up arrow or a down arrow.
i have rarely seen this, so thought i would mention it. this method might be able to simplify a study for someone.
i didn't take the time to modify the original , so both arrows would plot. i just commented them out and added 2 separate plots to display them.

#signal.SetPaintingStrategy(if crossingType == CrossingType.above
# then PaintingStrategy.BOOLEAN_ARROW_UP
# else PaintingStrategy.BOOLEAN_ARROW_DOWN);
That is an excellent find, thank you.
 

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