FAANG Percent Change per session

JohnnyMustard

New member
Hello, I've written the basics of a % Change for the 'FAANG' stocks, plotted on the left axis. The code is included.
On the right axis, I plot /ES and trade that. The market opens (for me) at 630am PST.
I'm having 2 problems.
1) The % Change doesn't begin each session at 0%. Shouldn't it? How can I get it to start at 0% each session?
2) There are unexplained gaps in my indicator, oddly enough usually around 10am PST each day.
In the pic you can see the 10am break for everyday this week.
ToS_PctChg.jpg
ToS_PctChg.jpg
It's driving me nuts, lol. Any help is greatly appreciated.

input AnchorDate = 20230523;
input AnchorTime = 0631;

input F = "Meta";
input A = "Amzn";
input A2 = "Aapl";
input N = "Nflx";
input G = "Goog";

def PostAnchorDate = if GetYYYYMMDD() >= AnchorDate then 1 else 0;
def PostAnchorTime = if SecondsFromTime(AnchorTime) >= 0 then 1 else 0;


def Fin = if PostAnchorDate and PostAnchorTime then (hl2(F) + hl2(A) + hl2(A2) + hl2(N) + hl2(G)) else 0;
plot FinPctChg = ((Fin - Fin[631]) / Fin[631]) * 100;
plot Zero = 0;
 
Hello, I've written the basics of a % Change for the 'FAANG' stocks, plotted on the left axis. The code is included.
On the right axis, I plot /ES and trade that. The market opens (for me) at 630am PST.
I'm having 2 problems.
1) The % Change doesn't begin each session at 0%. Shouldn't it? How can I get it to start at 0% each session?
2) There are unexplained gaps in my indicator, oddly enough usually around 10am PST each day.
In the pic you can see the 10am break for everyday this week.

It's driving me nuts, lol. Any help is greatly appreciated.

input AnchorDate = 20230523;
input AnchorTime = 0631;

input F = "Meta";
input A = "Amzn";
input A2 = "Aapl";
input N = "Nflx";
input G = "Goog";

def PostAnchorDate = if GetYYYYMMDD() >= AnchorDate then 1 else 0;
def PostAnchorTime = if SecondsFromTime(AnchorTime) >= 0 then 1 else 0;


def Fin = if PostAnchorDate and PostAnchorTime then (hl2(F) + hl2(A) + hl2(A2) + hl2(N) + hl2(G)) else 0;
plot FinPctChg = ((Fin - Fin[631]) / Fin[631]) * 100;
plot Zero = 0;


not sure what you are trying to do.

when i enable left axis for the study, the chart won't load.

input AnchorDate = 20230523;
input AnchorTime = 0631;

what do want this code line to do?
def Fin = if PostAnchorDate and PostAnchorTime then (hl2(F) + hl2(A) + hl2(A2) + hl2(N) + hl2(G)) else 0;

what do want this code line to do?
plot FinPctChg = ((Fin - Fin[631]) / Fin[631]) * 100;

Fin[631] , means go back in time 631 bars and read a value. it is not time related.

---------------

do you want to compare the price at 6:30 am to the prices during the rest of the day?

/ES trades 23 hours a day. most stocks trade 6.5 hours , so if one of them doesn't have a candle at a specific time, there will be no price data and no plot. your plots may look different because of the > in the time formula, not sure.

since i'm not sure what you want, and stocks don't trade at 6:30, i made something simple for now,
this reads the prices at 9:30, the normal open, and compares that to the prices during the rest of the day. this starts at 0 each day at 9:30.

i made this a lower study.

Code:
declare lower;

def na = double.nan;
def bn = barnumber();

input AnchorDate = 20230523;
#input AnchorTime = 0631;
input AnchorTime = 0930;

input F = "Meta";
input A = "Amzn";
input A2 = "Aapl";
input N = "Nflx";
input G = "Goog";

#def PostAnchorDate = if GetYYYYMMDD() >= AnchorDate then 1 else 0;
#def PostAnchorTime = if SecondsFromTime(AnchorTime) >= 0 then 1 else 0;
def t = if SecondsFromTime(AnchorTime) == 0 then 1 else 0;

#def Fin = if PostAnchorDate and PostAnchorTime then (hl2(F) + hl2(A) + hl2(A2) + hl2(N) + hl2(G)) else 0;
def combo = (hl2(F) + hl2(A) + hl2(A2) + hl2(N) + hl2(G));
def combostart = if t then combo else combostart[1];

#plot FinPctChg = ((Fin - Fin[631]) / Fin[631]) * 100;
def FinPctChg = ((combo - combostart) / combostart) * 100;

# dont plot last bar of period
def fin2 = if t[-1] then na else FinPctChg;

plot z1 = fin2;
plot Zero = 0;
#

shows a lower chart signal, that starts at 0, each day at 9:30am
JAkE3Se.jpg
 

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