PureBytes Links
Trading Reference Links
|
Greetings,
A week ago, my POP3 returned mail undelivered and I was bumped off the list.
Now resubscribed.
Over the last half year or so, I've noticed quite a few posts about problems
plotting daily averages (price, volume, TrueRange, etc) or coding intraday
strategies using daily data. As a 'swing trader' I base my entry decisions
on daily data and some external fundamentals. My TS7 autotrading strategies
work intraday (5M 15M or 30M) to time entry and trigger exits. I needed an
easy way to simultaneous view DAILY Price and TrueRange MAs on the same
5Minute bar chart I was using for autotrading.
Some solutions have been suggested and tried;
Launch a second data stream with a daily time frame, and apply functions to
it: I found this very error prone and launching separate dataX streams
with daily data was real pain (I have 20 or so charts going at once).
Adjust a bar moving average to simulate a daily average (IE - a 10 day
"daily" average would be 780 5 minute bars). Other than being
computationally extremely inefficient, this kept generating error messages
when my Days Back did not match the function. Besides, I couldn't plot this
in a way that was easily differentiated from the normal bar averages.
While these techniques 'worked' they were poor bandaids and I found myself
running two charts - one intraday and one daily, just to avoid the hassle.
Finally I said, enough is enough, and wrote a function that updates 9 moving
averages (three each of price, Tick, and TrueRange), making it possible to
plot a selection of these daily averages overlayed on my 5min bar chart in a
stepwise, flat line segment fashion (IE the 5 day average of Close is
constant for all 78 bars of a 5 minute chart, but is updated the next day).
I'm finding it very easy and comfortable to use.
The function I/O is a oAvgAry[3,5] by reference array defined in the calling
strategy or indicator:
oAvgAry 0 1 2 3 4
5
MALength(I) PriceMA(O) TickMA(O) TrueRangeMA(O) not used
Valid(I/O)
0 0 (must be zero - row posts current daily single values) 1
1 5(default) Close(5) Tick(5) ATR(5) 0 1
2 10(default) Close(10) Tick(10) ATR(10) 0 1
3 20(default) Close(20) Tick(20) ATR(20) 0 1
The function itself returns a long/neutral/short indicator (1, 0, -1) based
on the 5 crossover 10 greater than 20 strategy - of course this can be
ignored as a dummy variable.
The function is computationally efficient in that it only updates the array
once per day, and then it computes each average as only 3 adds/sums and 1
divide rather than summing all values in the moving average. IMHO this is
worthwhile for long averages and many charts.
The code is fully remarked so it should be easy to follow and adapt. If
anyone wants a copy of the DailyMAs.eld file please give me a request. The
file includes the DailyMAs function, and the indicator I use to display 3
daily MAs over my intraday chart.
Regards, daver
|