Collecting OHLC for current timeframe and identifying the mode - stock

Essentially I want to collect all the data of the OHLC of a symbol and identify the most common (mode) numbers that are closest to each other within a 1 pip/point range.
To clarify I want the most common point where price closes on 1 timeframe within a specific price range.

Related

How to bypass default parameter to include a range or better SQL?

EDITED (AGAIN): added tables and two screenshots (one of Google Sheets Chart and another showing mutliple issues in DS) to help demonstrate what I am seeing.
Short Version: I have created a parameter to help me score trending topics based on the date range filter. However, I want to be able to show a range of dates' worth of data, not just a specific date's worth of data. In theory, I could make the parameter a checklist with a huge range, but that doesn't seem efficient or sustainable down the road.
Disclaimer: I am about a week into SQL and Data Studio.
Long Version: We are tracking trends over time from a specific customer data set. I'd like to make it so that when a user adjusts the time range, various topics’ " score " depends on the end date. For instance, every time the topic "Recession" is brought up, it is given a score. That score is weighted based on when it was said. I was using 365 as the highest possible score so that anything over a year is null. So if "Recession" is referenced twice, once a week ago and once today, the avg score for recession is 361.5, but if a reference is made to the topic "Talent Management" twice today, then it would have a score of 365, and so forth across a growing list of 50+ topics pertaining to 50+ specific communities we are tracking the topics across.
Here is an example:
topics
groups
entry_date
recession
A
2022-11-24
talent mgt
A
2022-11-24
recession
B
2022-11-22
economy
A
2022-11-22
recession
C
2022-11-15
talent mgt
B
2022-11-8
This score would then affect the bubble size on a chart where the Y-axis is the count of unique groups referencing the topics, and an x-axis based on the range of average scores.
The goal is to be able to see which topics are the most common across groups, which ones are emerging trends, and which ones are dated trends by having a range slider. That way users (colleagues in other departments) can play with the date range "see" the bubbles moving in location and size.
example of static chart in google sheets
I could then also use the same data and fields to measure the percentage of topics being discussed across groups based on the weighted averages against a time range.
In Goolge Sheets I can do this with an xLookUp to a tab that has a column of 0-365 and then next to it a column of 365-0 (on a tab called 'scales') and then a cell on a sheet that you can put any date as the point in time, and it affects all the scores, tables, charts, etc. (I used. =xlookup((point_in_time - entry_date), 'scales'!A:A, 'scales'!B:B, "0")
In the data studios custom SQL I used:
SELECT
*
FROM
`qRaw_data'
where
DATE(_entry_dates_) between
parse_date('%Y%m%d', #DS_START_DATE) and
parse_date('%Y%m%d', #DS_END_DATE)
AND
#pit_date_diff = date_diff(
parse_date('%Y%m%d', #ds_end_date),
_entry_dates_,
day
)
Then I created a field that is time_score of:
avg((Pit_Date_Diff-365)*(-1))
I have been googling and youtubing like crazy and think I either have to come up with a way to override the #pit_date_diff default value OR I need to use a CASE WHEN in the custom query where each time the date_diff is 1 then 365, and so on, but when I try that I get all sorts of errors.
I would like below to include all topics averaged based on all entry dates, not just those that correlate with the inputted parameter field.
currently, I can only show specific entry dates due to the parameter
I appreciate any and all help. I am a week into using data studio and am going cross-eyed Googling and YouTubing things. There is likely a better logical path to accomplish all this. Hoping for a holiday miracle.
Thanks in advance.
It turns out this was much easier than I realized... I added an AS syntax to create a column and then created a field that created the same metrics that I had in the Google Sheets:
SELECT
*,
(date_diff(parse_date('%Y%m%d', #ds_end_date), _entry_dates_,day)) AS q_time_diff
FROM
`qRaw_data`
Then the score field is: (avg(q_time_diff)-365)*(-1)
In case that helps any others in the future... ¯\(ツ)/¯
Happy Holidays!

Computing XNPV in Power BI based on specific starting date?

I am trying to compute the NPV "Net Present Value" of a series of cash flows in PowerBI, using the XNPV formula, but want to be able to specify at which date the calculation should start.
I have 1 data table with 2 columns, "Month Ending", and "Value". The "Month Ending" column contains dates using the "Date" datatype, that are monthly for 40 years (following month end convention, I.E., 12/31/2022, 1/31/2023, 2/28/2023 etc...). The second column contains numbers of the data type "Fixed Decimal", representing the cash flow expected to occur in each monthly period. Additionally, I have a "What-If" parameter, of the "Decimal" data type, that can take a value between 0 and 1.
What I am able to do currently is compute the NPV of the entire cash flow series using the "XNPV" formula. What I want to be able to do is specify the exact starting point that the XNPV calculation should begin at.
Suppose we could create a parameter "Sale Date", that is is say 12/31/2024. I want a formula that would tell me what the XNPV is on 12/31/2024, using all cash flows that occur after 12/31/2024.
Ideally, I should be able to control this date using a slicer, and add it to a card on my display. The goal is to have the user drag a slider for the "Sale Date", and to see the value update on the card visual in real time. The end user should not have to modify any DAX expressions or Power Queries to change the result.
I have been struggling with this issue for a while, and cannot find any solutions that are dynamic in the way that I have described. Is what I am asking for even possible in PowerBI?
Thanks!

Qlikview - Target missing where no actual value

I have a fact table of Delay by Date by Category (and many other Fields). I have another (target) table of DelayTarget by Month and Category.
I am currently associating the target table to the fact table on Month & Category but when there is no Delay for a given Category in a given Month, then the DelayTarget value does not display in my dashboard.
How do I associate the DelayTarget to all Months in my main dataset - even when there is no Delay to report? I think I want to create a Zero value for Delay when it is null but I don't know how to do this or if this is the best method.
You need to create MasterCalendar to fill gap in dates.
I can give you more detailed answer but the best would be to share you data model (ctrl +T) and some example data from tables (or even better just.qvw)

Sliderinput Shiny from own dataset

I'm currently working on a shiny app, but I've got some problems with a slider input. I've got 500.000 variables called 'duration' which all correspond a specific 'price'. However, the range of the duration is between 1-around 50000, so min - max isn't working properly. Therefore I want to address the duration based on my own data duration data set(skipping duration numbers which don't exist) and match the corresponding price with that duration. As there are many durations with different prices, a histogram seems to be most logical.
So my question, how do I customize these sliders with my own data?

Calculating the average percentage of a bunch of figures in Excel?

Basically, I'm trying to calculate the total average outage hours of a worksheet I'm working with, however I'm trying to have it further broken down.
Here is a picture of the Excel Sheet:
Excel Calculations
(Not allowed to add embedded pictures yet :( - 10 reputation needed, sorry!)
Pretty much, I'm trying to calculate what the average up-time is for the month, by calculating the average downtime and then subtracting it from 100.00%
What I've got works, but I'm trying to workout whether the Outage Hours column can be scrapped, and the total can be calculated with perhaps just a larger formula.
Here is a link to the spreadsheet: https://www.dropbox.com/s/msowjndootd2hh2/Spreadsheet%20Calculations.xlsx?dl=0
Thanks in advance!
Just to clarify, you're looking for the result from the second column without having to include the second column, correct?
Since the second column is just the remaining difference (from 1.00) of the first column, then to get the result, all you have to do is take the remaining difference for the maximum overall to the total sum of the first column.
Meaning (assuming 12 months)...:
=12-SUM(B4:B15)
(Substitute 12 for however many months to be summed)
EDIT: OP is looking for =AVERAGE(B4:B15)