How to Plot a Daily Chart using an Intraday Base Scale
Author: mafiat
Creation Date: 5/27/2009 4:39 PM
profile picture

mafiat

#1
I need to plot a daily chart using 1min Intraday base data scale.

I am building a Effective Volume indicator on a Daily Scale. To build this indicator I need Intraday data. So I have to set the data series in the intraday mode. But I am having hard time to plot on a daily basis.

Can you help me??? Please
profile picture

Cone

#2
I think you're telling me that you want to access intraday data from a Daily chart and create a Daily indicator from that intraday data?

If that's it, it's somewhat backwards from the traditional way of mixing scales, which requires that you work from a chart with the lowest scale required. Then for indicators, you can rescale the base scale data (intraday) to create the higher scale (daily) indicators.

While it's easy to access intraday data from a daily chart, there's no easy way to work with it in the Daily scale's context. Essentially, you'd have to run through the intraday Bars and generate a single indicator value for each day, and manually synch it to the Daily series. It's really not too hard, but how exactly you accomplish that depends on where (and what format) you have the intraday data.

--- Just thinking out loud...
Synchronize does work going from intraday to daily, but there's no way to deterministically SetContext to the same symbol in another scale. If there were, you could actually create the indicator in the intraday DataSeries context, RestoreContext, and then just Synchronize it in the Daily scale.

Anyway, if you want more help, you'll need to answer the question about the format of the intraday data and how exactly the Effective Volume indicator is created.
profile picture

mafiat

#3
Yes. You are right.

What I exactly need to do is:

1) Get intraday 1-min bars and for each bar see there was price change from previous bar. If there was no price change, I will make that Bar volume equal to zero. For the remaining bars, I will apply the EV formula that is - EV = (ABS(Close - Closeprev)+0.01)/(High-Low+0.01)*Volume*((Close-ClosePrev)/(ABS((Close-ClosePrev))).

2)Then I sum the EV for each day and plot the result of the sum on a daily chart.

------

I have the script below for AFL and wanted to convert it to wl5.

Hope you can help.

Mafiat



_SECTION_BEGIN("NP Total Effective Volume");

_evFormula = Param("EV fomula", 0, 0, 1);

_ignoreOpeningBar = Param("Ignore Opening Bar", 1,0,1);

_slowEmaPeriods = Param("Slow TEV EMA Days", 22, 2, 255);
_fastEmaPeriods = Param("Fast TEV EMA Days", 10, 2, 255);

_erPeriods = Param("Effective Ratio periods", 5.3, 2, 64, 0.1);

_displayER = Param("Display Effective Ratio", 0,0,1);

_priceMovementThreshold = Param("Price movement threshold", 1, 1, 100, 0.1);
_blockFilteringThreshold = Param("Block order volume threshold", 5, 1, 100);

// Calculate total daily volume by collapsing 1-minute volume to daily
_dailyVolume = TimeFrameCompress(Volume, inDaily, compressVolume);

// Expand again to current (i.e. 1-minute) timeframe,
// thus making total Volume available at each 1-minute bar
_refVolume = TimeFrameExpand(_dailyVolume, inDaily, expandFirst);

_date = DateNum();

_diff = Close - Ref(Close,-1);
_th = IIf(Ref(C,-1) > H, Ref(C,-1), H);
_tl = IIf(Ref(C,-1) < L, Ref(C,-1), L);

// Filter out bars with block orders using block limit threshold
_flowVolume = IIf( (_priceMovementThreshold > abs(_diff / Close) * 100) AND
(Volume> _refVolume * _blockFilteringThreshold / 100) , 0, Volume);

if (_evFormula == 0) {
// Pascal's original formula
_evBar = sign(_diff) * (abs(_diff) + 0.01) * _flowVolume / (_th - _tl + 0.01);
} else {
// My variation
_evBar = _diff * _flowVolume * IIf(_th != _tl, 1/(_th - _tl), 1);
}

_ev = Null;
_tv = Null;

if (_ignoreOpeningBar == 1) {
_ev = IIf(_date == Ref(_date,-1), _evBar, 0);

} else {
_ev = _evBar;

}

// Total effective volume
_tev = Cum(_ev);

// Total effective ratio
if (_displayER == 1) {

_tv = Cum(Volume);
_er = Sum(_ev, _erPeriods * 600) / Sum(_tv, _erPeriods * 600);
Plot(EMA(_er,_erPeriods*600), "Total Effective Ratio", colorGreen, styleLine|styleLeftAxisScale);

}

Plot(_tev, "Total EV", colorBlack, styleLine);

_fast = EMA(_tev, 388 * _fastEmaPeriods);
_slow = EMA(_tev, 388 * _slowEmaPeriods);

Plot(_fast, "Fast TEV EMA", colorBlue, styleLine);
Plot(_slow, "Slow TEV EMA", colorRed, styleLine);

_SECTION_END();
profile picture

Cone

#4
Here's your EV "on the fly" (not a formal indicator) -

CODE:
Please log in to see this code.
Note! This logic assumes that intraday data exists for each Daily bar (at least from the start of the intraday data). If there isn't, the data is out of synch and you'll get a runtime error.
profile picture

mafiat

#5
Hi Cone,

I really appreciate your help!!

I tring to make it work without success. I have created 2 DataSets:

Test_1 - DataSet with 1-Minute Scale
Test Daily - Another DataSet with Daily scale (this one has the same Symbols as in Test_1)

I implemented your script using - "Bars mBars = GetExternalSymbol("Test_1", Bars.Symbol, false);".

And I was running the script using Test Daily DataSet on a daily scale.

But I have a problem. I tried to printdebug the mBars.Count (which is supposed to be the 1Minute Series for the specific Symbol), but suprisingly I got the total bars of a Daily Scale rather than on a 1Minute Scale.

Do you know why? How can we use Daily Chart Scale and still access a 1Minute intraday data (i.e, from mBars as created).

Thank you so much,

Mafiat
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).