Need help for background shading a range from previous trading day

hey

New member
VIP
Would anyone know how to create a code which put imple white background shading on today's chart covering a range of the following 6 items;

THE LAST 30 MINUTES OF PREVIOUS DAY'S:

1) 20 sma
2) 20 ema
3) 200 sma
4) 200 ema
5) closing price

6nd

THE LAST 45 MINUTES OF THE PREVIOUS DAY'S:

6) Price action (the candlestick price info range)
 
Would anyone know how to create a code which put imple white background shading on today's chart covering a range of the following 6 items;

THE LAST 30 MINUTES OF PREVIOUS DAY'S:

1) 20 sma
2) 20 ema
3) 200 sma
4) 200 ema
5) closing price

6nd

THE LAST 45 MINUTES OF THE PREVIOUS DAY'S:

6) Price action (the candlestick price info range)

sorry i don't know what you want. your description is vague.

go find windows 'snipping tool' and grab a screen shot of a chart.
then draw on the image to show what you want to see.

a range is between 2 numbers. but you list 5+? between what 2 price levels do you want shading?

6) price action is meaningless. you are asking people to write a program. a program uses math, which uses absolute values. there is only open, high, low, close. use those to describe what you want.
 
here is something to experiment with.

it draws 4 average lines

during the last 30 minutes of the day, it draws the 4 average lines, from yesterday

4 labels, that show the average parameters and line colors


Code:
# prev_days_avgs

#https://usethinkscript.com/threads/need-help-for-background-shading-a-range-from-previous-trading-day.22388/
#Need help for background shading a range from previous trading day
#hey  5/14

#Would anyone know how to create a code which put imple white background shading on today's chart covering a range of the following 6 items;

#THE LAST 30 MINUTES OF PREVIOUS DAY'S:

#1) 20 sma
#2) 20 ema
#3) 200 sma
#4) 200 ema
#5) closing price

#6nd

#THE LAST 45 MINUTES OF THE PREVIOUS DAY'S:

#6) Price action (the candlestick price info range)


def na = Double.NaN;
def bn = BarNumber();
def data = close;


input start = 1530;
input end = 1600;
def time1 = (secondsfromTime(start) >= 0 and secondstillTime(end) > 0);
def start30 = (secondsfromTime(start) == 0);


def startbn;
if start30 then {
 startbn = bn;
} else {
 startbn = startbn[1];
}


input avg1_type = AverageType.SIMPLE;
input avg1_length = 20;
def avg1 = MovingAverage(avg1_type, data, avg1_length);

input avg2_type = AverageType.exponential;
input avg2_length = 20;
def avg2 = MovingAverage(avg2_type, data, avg2_length);

input avg3_type = AverageType.SIMPLE;
input avg3_length = 200;
def avg3 = MovingAverage(avg3_type, data,  avg3_length);

input avg4_type = AverageType.exponential;
input avg4_length = 200;
def avg4 = MovingAverage(avg4_type, data,  avg4_length);


input show_avg_lines = yes;
plot zavg1 = if show_avg_lines and avg1_length > 0 then avg1 else na;
plot zavg2 = if show_avg_lines and avg2_length > 0 then avg2 else na;
plot zavg3 = if show_avg_lines and avg3_length > 0 then avg3 else na;
plot zavg4 = if show_avg_lines and avg4_length > 0 then avg4 else na;

zavg1.SetDefaultColor(Color.CYAN);
#zavg1.SetLineWeight(1);
zavg1.HideBubble();
zavg2.SetDefaultColor(Color.YELLOW);
#zavg2.SetLineWeight(1);
zavg2.HideBubble();
zavg3.SetDefaultColor(Color.MAGENTA);
#zavg3.SetLineWeight(1);
zavg3.HideBubble();
zavg4.SetDefaultColor(Color.WHITE);
#zavg4.SetLineWeight(1);
zavg4.HideBubble();

#---------------------------------------

# find prev day avg values

def off;
def prev1;
def prev2;
def prev3;
def prev4;
if bn == 1 then {
 off = 0;
 prev1 = 0;
 prev2 = 0;
 prev3 = 0;
 prev4 = 0;

} else if start30 then {
 off = (startbn - startbn[1]);
 prev1 = getvalue(avg1, off);
 prev2 = getvalue(avg2, off);
 prev3 = getvalue(avg3, off);
 prev4 = getvalue(avg4, off);

} else if time1 then {
 off = off[1];
 prev1 = getvalue(avg1, off);
 prev2 = getvalue(avg2, off);
 prev3 = getvalue(avg3, off);
 prev4 = getvalue(avg4, off);

} else {
 off = 0;
 prev1 = 0;
 prev2 = 0;
 prev3 = 0;
 prev4 = 0;
}


plot zp1 = if prev1 > 0 then prev1 else na;
plot zp2 = if prev2 > 0 then prev2 else na;
plot zp3 = if prev3 > 0 then prev3 else na;
plot zp4 = if prev4 > 0 then prev4 else na;
zp1.SetDefaultColor(Color.CYAN);
zp1.SetLineWeight(2);
zp1.HideBubble();
zp2.SetDefaultColor(Color.YELLOW);
zp2.SetLineWeight(2);
zp2.HideBubble();
zp3.SetDefaultColor(Color.MAGENTA);
zp3.SetLineWeight(2);
zp3.HideBubble();
zp4.SetDefaultColor(Color.WHITE);
zp4.SetLineWeight(2);
zp4.HideBubble();


#-----------------------

AddLabel(avg1_length > 0,  "1. " + 
(if avg1_type == AverageType.SIMPLE then "SMA"
 else if avg1_type == AverageType.EXPONENTIAL then "EMA"
 else if avg1_type == AverageType.HULL then "HULL"
 else if avg1_type == AverageType.WEIGHTED then "WT"
 else if avg1_type == AverageType.WILDERS then "WILD"
 else "---") + avg1_length 
, zavg1.TakeValueColor());

AddLabel(avg2_length > 0,  "2. " + 
(if avg2_type == AverageType.SIMPLE then "SMA"
 else if avg2_type == AverageType.EXPONENTIAL then "EMA"
 else if avg2_type == AverageType.HULL then "HULL"
 else if avg2_type == AverageType.WEIGHTED then "WT"
 else if avg2_type == AverageType.WILDERS then "WILD"
 else "---") + avg2_length 
, zavg2.TakeValueColor());

AddLabel(avg3_length > 0,  "3. " + 
(if avg3_type == AverageType.SIMPLE then "SMA"
 else if avg3_type == AverageType.EXPONENTIAL then "EMA"
 else if avg3_type == AverageType.HULL then "HULL"
 else if avg3_type == AverageType.WEIGHTED then "WT"
 else if avg3_type == AverageType.WILDERS then "WILD"
 else "---") + avg3_length 
, zavg3.TakeValueColor());

AddLabel(avg4_length > 0,  "4. " + 
(if avg4_type == AverageType.SIMPLE then "SMA"
 else if avg4_type == AverageType.EXPONENTIAL then "EMA"
 else if avg4_type == AverageType.HULL then "HULL"
 else if avg4_type == AverageType.WEIGHTED then "WT"
 else if avg4_type == AverageType.WILDERS then "WILD"
 else "---") + avg4_length 
, zavg4.TakeValueColor());

#
 

Attachments

  • img1.png
    img1.png
    145.5 KB · Views: 25
sorry i don't know what you want. your description is vague.

go find windows 'snipping tool' and grab a screen shot of a chart.
then draw on the image to show what you want to see.

a range is between 2 numbers. but you list 5+? between what 2 price levels do you want shading?

6) price action is meaningless. you are asking people to write a program. a program uses math, which uses absolute values. there is only open, high, low, close. use those to describe what you want.
thx will do.
 

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