Click here to Login

                                                   How to detect that a symbol has user-added notes?


Josh McCormick
2020-11-14 12:39:15

This should be a simple question, but my brain has decided to go on vacation without me this week. What would be the way to detect if the user has created any notes for the current symbol? I'd like to store the result as a 1 (has notes) or a 0 (no notes) in the variable "HasNotes" to make an on-screen indicator (shown below). It would display a tiny blue box in the upper-right corner with the letter "N" if any notes exist for the current symbol:

PrintChart("N", "", TopRight, colorWhite, colorWhite, colorBlue, 255*HasNotes);

So... I guess I know that the Notes function (Control-N) stores the user's notes in a Custom Database called "_notes". I'm just fuzzy on how I'd code a test to see if it is empty or not?

Thanks much,
Josh McCormick

Kyra Packens
2020-11-15 18:49:21


See if this works for you:

note = GetDataCount('_notes', 'note');
has_note = lastvalue(sum(note));
PrintChart(iffstr(has_note, has_note."N", ""), "", TopRight, colorWhite, colorWhite, colorBlue, 255*has_note);

Or try this if you want an indicator on the date of the note:

PlotArrow(note, "note", AboveHigh, colorBlue);

-- KP

edit: fixed a bug

Josh McCormick
2020-11-15 19:51:23



A total count in the upper-right *and* a set of vertical arrows to individually call out each day on-screen that has notes? Quite nice! I'd say that 95% solves what I'm looking for!

As it turns out, the remaining 5% of the problem represents an unexpected twist:
Some of my notes are coming to me from the future! :) They're in the database, but the functions are only counting past and present notes. Any thoughts on how to count any upcoming notes? (Or some other way to obtain the complete total of entries in the _notes database?)

Very appreciated,
Josh McCormick

Kyra Packens
2020-11-15 21:07:08


Best Answer
Hmm, I think I understand what you're looking for. Try this:

note = GetDataCount('_notes', 'note');
total_notes = lastvalue(sum(note));
notes = sum(note);
notes_prior = sum(note);
notes_after = total_notes - notes_prior;

// The total number of notes for the symbol
PrintChart(iffstr(total_notes, total_notes."N", ""), "", TopRight, colorWhite, colorWhite, colorBlue, 255*total_notes);

// The total number of notes on or prior to the day the cursor is over
//PrintChart(iffstr(total_notes, notes_prior."N", ""), "", TopRight, colorWhite, colorWhite, colorBlue, 255*total_notes);

// The total number of notes after the day the cursor is over
//PrintChart(iffstr(total_notes, notes_after."N", ""), "", TopRight, colorWhite, colorWhite, colorBlue, 255*total_notes);

Hope it helps!
-- KP

Josh McCormick
2020-11-24 17:22:25


That is VERY NICE Kyra, thank you!

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
Detect and Display Potential Splits on a Chart
Ticker Symbol Index
How far are the close prices from the support line
Volume near Price Level - Detect Strong Support & Resistance Area...
Stock Trading Rules - Percentage That Passed in the Last Trading ...

How-to Lessons
How to detect stocks trading near all time highs
How to plot a time-series that do not update the chart scale
How to rename a ticker symbol
How to quickly add a ticker symbol
How to detect whether price movements are predictable or not

Related Forum Threads
How do I refer to the close price of another symbol in a formula?
How to download a item that need a user and password
How to trade one symbol based on indicators of another?
How to clean the database: has anybody done this?
How to create a watchlist of scrips that are in an intermediate u...

Blog Posts
How to create a trading indicator that uses stock news
How to Detect Potential Issues/Errors in Your Historical Data?
How to Pick the Best Trend Indicators
Update Chart Layout based on Active Ticker Symbol
Industry Analysis - How to Compare Stocks with their Industries

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2023
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.