Hi Experienced Amibroker Programmers,
I have a problem with multiple time frame charting.
I want to plot weekly RSI on the daily chart. This is what I do:
rsiW = RSI(10);
However, the plot was using future data. For example, on last Wednesday, the weekly RSI value was based on last Friday's close.
Is there a parameter to force the weekly RSI calculation to use Wednesday's close on Wednesday etc.?
Or any tricks to accomplish this? (Probably need to construct some artificial arrays based partially on the timeframe compression I would think).
Read the manual CAREFULLY and SLOWLY, it explains various expand modes and how to use them Multiple Time Frame support
Just read it -everything is there. And no, your assumptions are incorrect. By default (expandLast) weekly data from given week are available at the END of Friday. This is how it works - and it is described in manual.
That’s exactly what I meant. Only on Fridays, the weekly plot (based on close) were correct! On Mondays to Thursdays, the weekly plot value is the same as on Fridays, because it uses Fridays’ data.
What I want is on Mondays to Thursdays, their daily close values are used as the weekly close for THAT day, instead of Fridays close values. For example, calculating a 10 weekly moving average, the first 9 values are from the 9 weekly closes, but the last value should be the daily close as the week is not yet completed.
This can likely be done through some low level array manipulation. I was checking if there was an easy way, but obviously not.
No it isn’t. You don’t understand how it works. Reread the manual. If you use expandLast, till Thursday you will get previous week data.
In weekly timeframe data change on every Friday. If you expand weekly to daily, Monday to Thursday contain data from PREVIOUS WEEK’S FRIDAY
To get better understanding how functions work, use advice given here: How do I debug my formula?
Thanks Tomasz, you are right, that's a misunderstanding on my part.
But that's not what I want. From Monday Til Thursday, I not only want to use previous weeks data, I also want to use the data from current week. i.e. on Monday, I want to use Monday's close as the current weekly close; on Tuesday I want to use Tuesday's close as the current weekly close. etc.
This is similar to calculating the daily moving average during trading hours, you use the last price as today's close even though today has not finished yet. You don't ignore today's data and just use yesterday's close as the last close.
As it is explained in the manual, WEEKLY time frame means ONE BAR per WEEK.
You want multiple data bars per week (different for each day of the week). That is NOT WEEKLY mode.
What you want is something completely different. You can do that but not using TimeFrame functions.
What you really want is not weekly data. That is DAILY data that gets summed processed so Close remains the daily close, while High and Low are highest/lowest daily points since Monday and Volume is sum since monday. But it is still daily interval (one bar per day, not week).
It can be done completely without TimeFrame functions as there is NO time compression of data.
NewWeek = DayOfWeek() < Ref( DayOfWeek(), -1 );
OnGoingClosePerWeek = Close;
OnGoingHighPerWeek = HighestSince( NewWeek, High );
OnGoingLowPerWeek = LowestSince( NewWeek, Low );
OnGoingVolumePerWeek = SumSince( NewWeek, Volume );
If you want previous day close, you can use this:
OnGoingClosePerWeek = Ref( Close, -1 );
If you want previous day values of other arrays, use Ref() as well.
Yes Yes Yes! That's what I look for. Thanks a million Tomasz.
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.