Superimpose scatter data points on line charts in loop
Hi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
AmitHi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
Amit Hi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
Amit scatter and line chart superimposed in one loop MATLAB Answers — New Questions