Date of MACD Cross on Daily Chart

british43

Member
VIP
Hello, How would I go about adding a date chartbubble at each instance where there is a MACD cross? I have been knocking my head all day trying to figure it out. Thanks.
 
Solution
Duplicate the MACDHistogramCrossover study and add this at the bottom. Where it has ATR*1.1 you can change that to adjust the vertical position. Such as 1.05 to get closer to the candles or 1.2 to get farther away.

Ruby:
AddChartBubble(
  signal,
  high + reference ATR * 1.1,
  GetMonth() + "/" + GetDayOfMonth(GetYYYYMMDD()) + "/" + AsPrice(GetYear()),
  Color.LIGHT_GRAY
);
Duplicate the MACDHistogramCrossover study and add this at the bottom. Where it has ATR*1.1 you can change that to adjust the vertical position. Such as 1.05 to get closer to the candles or 1.2 to get farther away.

Ruby:
AddChartBubble(
  signal,
  high + reference ATR * 1.1,
  GetMonth() + "/" + GetDayOfMonth(GetYYYYMMDD()) + "/" + AsPrice(GetYear()),
  Color.LIGHT_GRAY
);
 
Solution
Duplicate the MACDHistogramCrossover study and add this at the bottom. Where it has ATR*1.1 you can change that to adjust the vertical position. Such as 1.05 to get closer to the candles or 1.2 to get farther away.

Ruby:
AddChartBubble(
  signal,
  high + reference ATR * 1.1,
  GetMonth() + "/" + GetDayOfMonth(GetYYYYMMDD()) + "/" + AsPrice(GetYear()),
  Color.LIGHT_GRAY
);
Can I get the full script for the MACD Crossover Please? Thanks
 
Thank you so much. Also, does thinkorswim has a limitation when trying to display dates in a watchlist? For example want to display the date of the MACD crossover in a watchlist column?
 
Thank you so much. Also, does thinkorswim has a limitation when trying to display dates in a watchlist? For example want to display the date of the MACD crossover in a watchlist column?

This will include both crossing above and crossing below. If you want just one or the other, change the line:
def signal = Diff crosses 0;
to
def signal = Diff crosses above 0;
or
def signal = Diff crosses below 0;

Also, if want it to be sortable you should rearrange the date formatting to be YYYY-MM-DD. TOS will sort the column as text, for instance
01/01/2020
01/01/2021
02/04/2020
etc.

Ruby:
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

def signal = Diff crosses 0;

def month = if signal then GetMonth() else month[1];
def dayOfMonth = if signal then GetDayOfMonth(GetYYYYMMDD()) else dayofMonth[1];
def year = if signal then GetYear() else year[1];

AddLabel(
  !IsNaN(month),
  month + "/" + dayOfMonth + "/" + AsPrice(year),
  Color.LIGHT_GRAY
);
 
This will include both crossing above and crossing below. If you want just one or the other, change the line:
def signal = Diff crosses 0;
to
def signal = Diff crosses above 0;
or
def signal = Diff crosses below 0;

Also, if want it to be sortable you should rearrange the date formatting to be YYYY-MM-DD. TOS will sort the column as text, for instance
01/01/2020
01/01/2021
02/04/2020
etc.

Ruby:
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

def signal = Diff crosses 0;

def month = if signal then GetMonth() else month[1];
def dayOfMonth = if signal then GetDayOfMonth(GetYYYYMMDD()) else dayofMonth[1];
def year = if signal then GetYear() else year[1];

AddLabel(
  !IsNaN(month),
  month + "/" + dayOfMonth + "/" + AsPrice(year),
  Color.LIGHT_GRAY
);
Thanks very much really appreciate you!
 
Duplicate the MACDHistogramCrossover study and add this at the bottom. Where it has ATR*1.1 you can change that to adjust the vertical position. Such as 1.05 to get closer to the candles or 1.2 to get farther away.

Ruby:
AddChartBubble(
  signal,
  high + reference ATR * 1.1,
  GetMonth() + "/" + GetDayOfMonth(GetYYYYMMDD()) + "/" + AsPrice(GetYear()),
  Color.LIGHT_GRAY
);
Slippage, I too am a Moxie Mastery member and a multi year Simpler Trading trade room member. I very much appreciate your coding and philosophy of streamlining the code to reduce computer resources. I am not skilled in Thinkscript. I would very much like to correspond with you concerning fine tuning some scan code for the Moxie (e.g. 50/200/50 and others) and some custom components to add to a multi compression squeeze radar screen (RAF Buy/Sell/Continuation on MTFs) that I use for day and swing trading.

If it is OK with you maybe we could exchange email addresses to correspond further through the useThinkScrip Admin or through Simpler Admin if you prefer. I am Gator in the Moxie and Day trading rooms.

Thanks for reading.

Uploaded image: "image.png"
 

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