To plot arrows on Daily Chart with Weekly plot criteria

8Nick8

Active member
2019 Donor
VIP
https%3A//i.imgur.com/IOk3bnP.jpg[/img]']
IOk3bnP.jpg


Hi, I would like to create a plot for the white arrows on the DAILY Chart when these conditions are met
1. The Weekly DPO line is below the Zeroline
2. 10Week EMA is below 30Week EMA
3. Weekly Close is greater than previous week close
Overview,
On left chart, the white arrows near the 4 white dotted lines are invalid because, the DPO line is above zeroline, marked on the Weekly chart.
The only valid WHITE arrow is being marked by the Blue line.

I am not sure if this is possible, and like to seek some help.

Thanks

#white arrow plot
Plot Trend1 = MovAvgExponential(close, 10);
Trend1.AssignValueColor(if close > Trend1 then Color.GREEN else Color.RED);
Trend1.SetLineWeight(1);
Plot Trend2 = MovAvgExponential(close, 30);
Trend2.AssignValueColor(if close > Trend2 then Color.GREEN else Color.RED);
Trend2.SetLineWeight(2);
Plot white = close > Trend1 and close<trend2 and Trend2 > Trend1;
white.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
white.SetLineWeight(3);
L5.AssignValueColor(COLOR.white);


##
input price = close;

# DPO parameters
input colorNormLength = 3;
input DPO_length = 14;

# MOBO parameters
input ColoredMobo = yes;
input ColoredFill = yes;
input BreakArrows = yes;
input MOBO_midline = no;
input MOBO_displace = 0;
input MOBO_length = 6;
input Num_Dev_Dn = -0.8;
input Num_Dev_Up = +0.8;

# Fuel Cell (MACD) inputs
input showMACD = no; # Turns the Fuel Cells on (yes) or off (no).
input MACDfastLen = 10; # standard MACD parameter.
input MACDslowLen = 15; # standard MACD parameter.
input MACDLen = 10; # standard MACD parameter.
input MACDScaling = 50; # Enlarge or shrink FuelCell size.
input MACDWidth = 3; # Width of individual FuelCell elements.
input MACDColors = {default "Cyan_Only", "Cyan_Magenta", "Red_Green"};
input level =-1;

plot Zeroline = 0;
ZeroLine.SetDefaultColor(GetColor(5));

plot DPO = price - Average(price[DPO_length / 2 + 1], DPO_length);
DPO.DefineColor("Highest", Color.Yellow);
DPO.DefineColor("Lowest", Color.Light_Red);
DPO.AssignNormGradientColor(colorNormLength, DPO.color("Lowest"), DPO.color("Highest"));
 
Hi, I would like to create a plot for the white arrows on the DAILY Chart when these conditions are met
1. The Weekly DPO line is below the Zeroline
2. 10Week EMA is below 30Week EMA
3. Weekly Close is greater than previous week close
Overview,
On left chart, the white arrows near the 4 white dotted lines are invalid because, the DPO line is above zeroline, marked on the Weekly chart.
The only valid WHITE arrow is being marked by the Blue line.

I am not sure if this is possible, and like to seek some help.

Yes, it's possible.

However, when you access higher timeframes they cause the smaller periods within those timeframes to continue updating until the higher timeframe period ends, commonly referred to as "repainting". For instance, on Monday you may have no arrow on the daily chart because the weekly conditions are not met. On Tuesday they are met and an arrow appears on both Monday and Tuesday. On Wednesday conditions are no longer met so the arrows are gone. Thursday conditions are met again and now you have arrows on Mon, Tue, Wed, Thu. This back and forth can continue until the close of the week on Friday.

You can access higher timeframes by specifying the aggregation period when you refer to prices. For instance, to get the 10 week EMA you can write:

Ruby:
def weekEma10 = ExpAverage(close(period=AggregationPeriod.WEEK), 10);

For each of your conditions based on weekly data you need to either update the code to accept the period as an input parameter or make a new version of the code that hard codes the period. This can be done either as new individual scripts or you could copy all of the code into your main script and do it there.
 
Yes, it's possible.

However, when you access higher timeframes they cause the smaller periods within those timeframes to continue updating until the higher timeframe period ends, commonly referred to as "repainting". For instance, on Monday you may have no arrow on the daily chart because the weekly conditions are not met. On Tuesday they are met and an arrow appears on both Monday and Tuesday. On Wednesday conditions are no longer met so the arrows are gone. Thursday conditions are met again and now you have arrows on Mon, Tue, Wed, Thu. This back and forth can continue until the close of the week on Friday.

You can access higher timeframes by specifying the aggregation period when you refer to prices. For instance, to get the 10 week EMA you can write:

Ruby:
def weekEma10 = ExpAverage(close(period=AggregationPeriod.WEEK), 10);

For each of your conditions based on weekly data you need to either update the code to accept the period as an input parameter or make a new version of the code that hard codes the period. This can be done either as new individual scripts or you could copy all of the code into your main script and do it there.

After taking careful consideration of the very good comments by @Slippage, see if this helps in your analysis.

Screenshot-2021-08-16-064925.jpg
Ruby:
##  Weekly White Arrow Defined

input agg = AggregationPeriod.WEEK;
def price = close(period = agg);

# DPO parameters
input colorNormLength = 3;
input DPO_length = 14;

# MOBO parameters
input ColoredMobo = yes;
input ColoredFill = yes;
input BreakArrows = yes;
input MOBO_midline = no;
input MOBO_displace = 0;
input MOBO_length = 6;
input Num_Dev_Dn = -0.8;
input Num_Dev_Up = +0.8;

# Fuel Cell (MACD) inputs
input showMACD = no; # Turns the Fuel Cells on (yes) or off (no).
input MACDfastLen = 10; # standard MACD parameter.
input MACDslowLen = 15; # standard MACD parameter.
input MACDLen = 10; # standard MACD parameter.
input MACDScaling = 50; # Enlarge or shrink FuelCell size.
input MACDWidth = 3; # Width of individual FuelCell elements.
input MACDColors = {default "Cyan_Only", "Cyan_Magenta", "Red_Green"};
input level = -1;

def Zeroline = 0;
#ZeroLine.SetDefaultColor(GetColor(5));

def DPO = price - Average(price[DPO_length / 2 + 1], DPO_length);
#DPO.DefineColor("Highest", Color.Yellow);
#DPO.DefineColor("Lowest", Color.Light_Red);
#DPO.AssignNormGradientColor(colorNormLength, DPO.color("Lowest"), DPO.color("Highest"));

def weekEma10 = ExpAverage(close(period = agg), 10);
def weekEma30 = ExpAverage(close(period = agg), 30);

def weeklywhite = weekEma10 < weekEma30 and DPO < 0 and price > price[1];

##  Daily White Arrow Defined
plot Trend1 = MovAvgExponential(close, 10);
Trend1.AssignValueColor(if close > Trend1 then Color.GREEN else Color.RED);
Trend1.SetLineWeight(1);
plot Trend2 = MovAvgExponential(close, 30);
Trend2.AssignValueColor(if close > Trend2 then Color.GREEN else Color.RED);
Trend2.SetLineWeight(2);
def dailywhite = close > Trend1 and close < Trend2 and Trend2 > Trend1;

## White arrow plot

plot white = dailywhite and weeklywhite;
white.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
white.SetLineWeight(3);
white.AssignValueColor(Color.WHITE);

##
 

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