LLP
Member
Hi, can someone make this code for the MA to be display for MA $ value and also arrow up or down. Please see photo. I highlight in blue and yellow.
no , i have no idea what you are asking for.Hi, can someone make this code for the MA to be display for MA $ value and also arrow up or down. Please see photo. I highlight in blue and yellow.
on the top part of the chart I put yellow arrow, and blue line, those are the $ value for SMA5 and it shows it is above SMA5 or below SMA5 with the arrow. All runs auto.no , i have no idea what you are asking for.
write out some sentences to describe the rules that the study should follow and what you want to see on the chart.
top chart, guessing 3 average lines ?
lower chart , ?? no idea
Do you understandno , i have no idea what you are asking for.
write out some sentences to describe the rules that the study should follow and what you want to see on the chart.
top chart, guessing 3 average lines ?
lower chart , ?? no idea
Do you understand
# avg_value_up_down_00
def na = double.nan;
def bn = barnumber();
#def lastbar = !isnan(close[0]) and isnan(close[-1]);
def price = close;
input ma1_len = 5;
#input ma1_type = AverageType.EXPONENTIAL;
input ma1_type = AverageType.simple;
def ma1 = round(MovingAverage(ma1_type, price, ma1_len),2);
input ma2_len = 10;
input ma2_type = AverageType.simple;
def ma2 = round(MovingAverage(ma2_type, price, ma2_len),2);
input ma3_len = 20;
input ma3_type = AverageType.simple;
def ma3 = round(MovingAverage(ma3_type, price, ma3_len),2);
def stackup = (ma1 > ma2 and ma2 > ma3);
def stackdwn = (ma1 < ma2 and ma2 < ma3);
input show_avg_lines = yes;
plot z1 = if show_avg_lines then ma1 else na;
z1.setdefaultcolor(getcolor(1));
z1.hidebubble();
plot z2 = if show_avg_lines then ma2 else na;
z2.setdefaultcolor(getcolor(2));
z2.hidebubble();
plot z3 = if show_avg_lines then ma3 else na;
z3.setdefaultcolor(getcolor(3));
z3.hidebubble();
input show_labels = yes;
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "MA" + ma1_len + ": " + ma1, (if ma1 > close then color.red else if ma1 < close then color.green else color.white));
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "MA" + ma2_len + ": " + ma2, (if ma2 > close then color.red else if ma2 < close then color.green else color.white));
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "MA" + ma3_len + ": " + ma3, (if ma3 > close then color.red else if ma3 < close then color.green else color.white));
addlabel(show_labels, " ", color.black);
addlabel(show_labels,
(if (stackup or stackdwn) then "Avgs stacked" else "--"),
(if stackup then color.green else if stackdwn then color.red else color.black));
#
# macd_value_up_down_00
# MACD
# TD Ameritrade
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#-----------------------------------
# compare current bar value to the value from previous bar
def isvalueup = (value > value[1]);
def isavgup = (avg > avg[1]);
def isdiffup = (diff > diff[1]);
input show_labels = yes;
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "MACD: " + value, (if isvalueup then color.green else color.red));
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "Avg: " + avg, (if isavgup then color.green else color.red));
addlabel(show_labels, " ", color.black);
addlabel(show_labels, "Diff: " + diff, (if isdiffup then color.green else color.red));
addlabel(show_labels, " ", color.black);
#
I try your code on ticker: TEAM it didn't show the same result of the XQ apps# avg_value_up_down_00 def na = double.nan; def bn = barnumber(); #def lastbar = !isnan(close[0]) and isnan(close[-1]); def price = close; input ma1_len = 5; #input ma1_type = AverageType.EXPONENTIAL; input ma1_type = AverageType.simple; def ma1 = round(MovingAverage(ma1_type, price, ma1_len),2); input ma2_len = 10; input ma2_type = AverageType.simple; def ma2 = round(MovingAverage(ma2_type, price, ma2_len),2); input ma3_len = 20; input ma3_type = AverageType.simple; def ma3 = round(MovingAverage(ma3_type, price, ma3_len),2); def stackup = (ma1 > ma2 and ma2 > ma3); def stackdwn = (ma1 < ma2 and ma2 < ma3); input show_avg_lines = yes; plot z1 = if show_avg_lines then ma1 else na; z1.setdefaultcolor(getcolor(1)); z1.hidebubble(); plot z2 = if show_avg_lines then ma2 else na; z2.setdefaultcolor(getcolor(2)); z2.hidebubble(); plot z3 = if show_avg_lines then ma3 else na; z3.setdefaultcolor(getcolor(3)); z3.hidebubble(); input show_labels = yes; addlabel(show_labels, " ", color.black); addlabel(show_labels, "MA" + ma1_len + ": " + ma1, (if ma1 > close then color.red else if ma1 < close then color.green else color.white)); addlabel(show_labels, " ", color.black); addlabel(show_labels, "MA" + ma2_len + ": " + ma2, (if ma2 > close then color.red else if ma2 < close then color.green else color.white)); addlabel(show_labels, " ", color.black); addlabel(show_labels, "MA" + ma3_len + ": " + ma3, (if ma3 > close then color.red else if ma3 < close then color.green else color.white)); addlabel(show_labels, " ", color.black); addlabel(show_labels, (if (stackup or stackdwn) then "Avgs stacked" else "--"), (if stackup then color.green else if stackdwn then color.red else color.black)); #
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
T | Adding options cost a $value for futures contract | Questions | 1 | |
5 | Identify POC Value High and Low | Questions | 0 | |
Candle Range Value | Questions | 4 | ||
D | ROC Strategy - need to use the closing value of each bar | Questions | 5 | |
C | Fair Value Gap zones make it appear after one get broken | Questions | 1 |
Start a new thread and receive assistance from our community.
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.
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.