Sum up Daily Market Sentiment on Weekly chart (Accessing Daily data from Weekly)
Author: ksarkar77
Creation Date: 10/29/2019 7:09 PM
profile picture

ksarkar77

#1
Hi There,

I am trying to access data in daily time scale from a weekly chart. I am getting error stating that 'Cannot convert Weekly Bars to Daily Scale'.

Does this mean in WealthLab I cannot access lower time frame data from higher time frame chart? Is there any other way I can accomplish this?

Thanks
Kuntal

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Hi Kuntal,

The answer to your question is not necessarily no but I want to be sure your problem is clear to me. What's the reason for using the Weekly scale when you can already do what you're doing with that code from the Daily chart? Please provide more insight as currently there's no great sense in the code which is trying to access a lower time frame from the higher time frame chart.
profile picture

ksarkar77

#3
Eugine,

I see your point and you are correct that we do not need it in most of the cases.

In this particular case, I am accessing sentiment data to migrate the sentiment indicators from Tradestation.For the symbol "NYSE_advn" when I look into daily, it says on 10/25 (Friday), it is 1647 advancing issues. When I look at the weekly chart, it shows the same 1647 advancing issues. What I wanted it to happen to sum up all the advancing issues for that week, so that I have a weekly number of total advancing issues for that week. And then apply logic to that newly created weekly data series.

In the example, I am trying to summarize the volume which is not required because it is already scaled up. However, I still need to have the total weekly number of advancing issues and that logic is still required.

Your help is greatly appreciated.

Thanks
Kuntal
profile picture

Eugene

#4
QUOTE:
When I look at the weekly chart, it shows the same 1647 advancing issues.

Right, because 1647 is the value on Friday and week ends on Friday. When compressing data into a higher bar scale, Wealth-Lab does not aggregate - and this is what you're actually trying to accomlish:

What I wanted it to happen to sum up all the advancing issues for that week, so that I have a weekly number of total advancing issues for that week.

So my understanding is that from Weekly chart you're aggregating (summing up) the OHLC values for the daily sentiment data using the Market Sentiment data provider. Let me think it over and come up with something. Currently deciding between a script-based workaround and adding an option to the Market Sentiment provider which would scale the data into a higher scale (Weekly, Monthly...) at the time of new DataSet creation. The latter might add some value but would take time and effort.

P.S. It's possible to access data from a lower bar scale. Refer to KB article: Accessing Intraday data from Daily. So, summing up the values may be approached using the daily series obtained like that.
profile picture

Eugene

#5
It occurred to me that probably the most universal way might be to introduce summation (aggregation) as as option to the EOD Scaling Provider. It can be used to create n-Day bars and more but its Weekly/Monthly charts build the OHLC bar - it cannot be used to sum up values (other than Volume).

Disregard. In your specific case, aggregation doesn't apply to OHL - just C. And the EOD Scaling provider creates compressed OHLC, not Close-only. That would neither be elegant nor universal.
profile picture

Eugene

#6
Kuntal, on Daily scale your task is pretty easy to achieve. Check out this simple script where the summed up NYSE advaning issues are plotted as running total:

CODE:
Please log in to see this code.


UPDATE: Fixed bug noticed by superticker in post #8
profile picture

ksarkar77

#7
Hi Eugene,

Thank you very much for the code sample.

What I am trying to achieve here is an indicator which works in weekly scale. How can I sum up daily scale value to weekly scale? In this example, my chart has to be on daily scale, right?


Update: I did not see your earlier post prior to sample you provided where you referred to KB article. Let me do some work around it. I will get back to you with results.

profile picture

superticker

#8
I think there's a weird error in the Post# 6 code. Either the first change below needs to be done:
CODE:
Please log in to see this code.

Or the second change needs to be done, but not both changes.
CODE:
Please log in to see this code.
(You can just delete this post after fixing it.)
---
I have an unrelated question. Could the Post# 6 solution be wrapped into an Index Lab solution? If so, would that be a good thing or a bad thing?
profile picture

Eugene

#9
QUOTE:
Update: I did not see your earlier post prior to sample you provided where you referred to KB article.

The challenges you may face here are: 1) when peeking inside that daily series you cannot rely on Monday/Friday to be the first/last day of the week because of market holidays and 2) DateTimeToBar cannot be used on the external symbol (Daily) Bars as it operates on the charted Bars object only.

QUOTE:
I have an unrelated question. Could the Post# 6 solution be wrapped into an Index Lab solution? If so, would that be a good thing or a bad thing?

I'm not sure. In your opinion, what would be the point?

QUOTE:
double _sum = 0.0;

Sorry, that's a bug. Thanks for the heads-up! Fixed.
profile picture

ksarkar77

#10
Thanks for the heads up Eugene. I guess I should wait to see your suggestion.
profile picture

superticker

#11
QUOTE:
Could the Post# 6 solution be wrapped into an Index Lab solution?

QUOTE:
In your opinion, what would be the point?
The point would be to hide the complexity of the solution into a Index Lab solution.

Perhaps I misunderstood the problem altogether. I was thinking this was about creating some "general index" to apply to many stocks when I saw the GetExternalSymbol(...) call. But perhaps I simply don't understand why the GetExternalSymbol(...) is being used in the first place here. It almost seems like an External Symbol isn't even involved. Why not just use Bars.Close directly if an External Symbol isn't really involved?
profile picture

Eugene

#12
Mark, please follow the Wiki link in post #4 (last paragraph). That KB article should explain the trick of using an external symbol where it's not even involved.
profile picture

ksarkar77

#13
Eugine,

Here is my attempt after your suggestions.
I have another indicator that needs to be plotted on a weekly chart using minutes data. My main challenge is now how to maintain a NYSE and NASDAQ symbols dataset in minutes data so that it can be accessed using a similar method. Any easier solution if you can think off would be really appreciated.

CODE:
Please log in to see this code.
profile picture

Eugene

#14
Hey Kuntal, kudos for a simple and elegant solution! Nice that it doesn't rely on day of week and handles holidays.

QUOTE:
I have another indicator that needs to be plotted on a weekly chart using minutes data.

Since Market Sentiment data doesn't exist for Minute scale this must be something else. If it's substantially different you might want to start a new topic?
profile picture

ksarkar77

#15
Hi Eugene,

The other indicator I am talking about is looking at price and volume data at a minute level but plots it at a weekly level. I saw some code regarding that, but it requires the creation of dataset set at minutes level. I am concerned about how to maintain the list of symbols current at that level. What I am planning is to grab the list from yahoo classification list from XML file and then create a dataset for Fidelity. That way it will remain updated. I am thinking of ways to automate it. Is there a command-line program I can call to refresh the yahoo classification XML file?

Also, one more quick question. How can I avoid plotting indicators for the last weekly bar? I came across ISLASTBAROFDAY function. But not sure how can I use it with PlotSeries function.

Thanks
Kuntal
profile picture

Eugene

#16
QUOTE:
Is there a command-line program I can call to refresh the yahoo classification XML file?

I'm a proponent of "one topic one problem" idea. If unrelated questions such as this are put into this topic this doesn't let us maintain the forum a searchable, live knowledge base. You're welcome to start a new topic for your question. It's free of charge :)

QUOTE:
Also, one more quick question. How can I avoid plotting indicators for the last weekly bar?

I see how it applies to the context of this thread: the last bar may be incomplete during week-to-date. Well, one cannot really avoid plotting on a bar altogether but SetSeriesBarColor with Color.Transparent could be used to make it disappear, for example.
profile picture

ksarkar77

#17
Thank you, Eugene. Very much appreciated.
profile picture

Eugene

#18
The Market Sentiment provider is depreciated. Effective 02/20/2020, MS123 supports the most frequently used market sentiment data through our Wealth-Data provider - the advancing, declining and unchanged issues for AMEX, NASDAQ and NYSE! Here are the symbols:

$AMEX_ADVN (AMEX Advancing Issues)
$AMEX_DECLN (AMEX Declining Issues)
$AMEX_UNCHN (AMEX Unchanged Issues)
$NASDAQ_ADVN (NASDAQ Advancing Issues)
$NASDAQ_DECLN (NASDAQ Declining Issues)
$NASDAQ_UNCHN (NASDAQ Unchanged Issues)
$NYSE_ADVN (NYSE Advancing Issues)
$NYSE_DECLN (NYSE Declining Issues)
$NYSE_UNCHN (NYSE Unchanged Issues)

You can create a W-D DataSet by copying/pasting the symbols or by choosing them from "MS" Classification Group in the New DataSet Wizard > Wealth-Data.
profile picture

Eugene

#19
UPDATE:

Effective 03/09/2020, get more market sentiment data using our Wealth-Data provider - the new highs and lows for AMEX, NASDAQ and NYSE! The new symbols are:

$AMEX_newhi (AMEX New Highs)
$AMEX_newlo (AMEX New Lows)
$NYSE_newhi (NYSE New Highs)
$NYSE_newlo (NYSE New Lows)
$NASDAQ_newhi (NASDAQ New Highs)
$NASDAQ_newlo (NASDAQ New Lows)
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).