[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Daily MA from Intra-day data



PureBytes Links

Trading Reference Links

Perhaps I've answered my own question. Check this out.
Set up another variable:
TradeDays = Day() >= 1 and Day() <=5;

Then I use this in the moving average??? But where?

 RngMinAvg = MA(ValueWhen(TradeDays,DlyRngMin) , 10);

or

 RngMinAvg = MA(DlyRngMin , ValueWhen(TradeDays,10));

I don't know, I've given up coding for today and haven't plugged these in to test them. I don't think it would work.


--- In amibroker@xxxxxxxxxxxxxxx, "Pete" <dryheat3@xxx> wrote:
>
> Ok, here's the problem, The program skews the calculation when you try to take intra-day Futures data and compress to daily. the compression into daily tweaks the whole thing up because of Sunday's and holidays. Yes, the program is taking any trading which occurs on Sunday night and holidays and including this in the range. I need to exclude non-trade days from the moving average range and every attempt to do so has found me yelling and screaming at the computer.
> 
> So my question is this. How to calculate the daily moving average of say, the lessor of (H-O) or (O-L), and use only the market trading hours, excluding Sundays and Holidays. My attempt below was to use the TimeOpen and TimeClose variables to restrict the O,H,L,C values I picked up along the way. This indeed works but when I try to create a moving average on a daily time frame it includes Sundays and Holidays in the 'Range' value of the moving average argument even though the trades occur outside of trading hours (Sunday) or do not trade the entire day (holidays).
> 
> TimeOpen = 093000;
> 
> TimeClose = 160000;
> CurBarTime = TimeNum();
> //Determine the value of the market open. Initial setting is for
> //9:30 AM to match US Market Open. Adjust as need for your market
> MrktOpen = ValueWhen(CurBarTime  == TimeOpen , Open);
> //Determine the highest high for each day's trading.
> //Adjust time as needed for your market.
> DlyHigh = HighestSince(CurBarTime  == TimeOpen , High);
> //Take a snapshot value of the day's high at the time of market 
> //close. Intial setting is 4:00 pm to match US Market Close. 
> //Adjust as needed for your market.
> DlyHighest = ValueWhen(CurBarTime  == TimeClose , DlyHigh);
> printf("DlyH: " +DlyHighest +"\n");//////////////////////////////
> //Do the same for the lowest value of the trading day.
> //Adjust time as needed for your market.
> DlyLow = LowestSince(CurBarTime  == TimeOpen , Low);
> DlyLowest = ValueWhen(CurBarTime  == TimeClose , DlyLow);
> printf("DlyL: " +DlyLowest +"\n");
> //determine the market closing price
> DlyClose = ValueWhen(CurBarTime  == TimeClose , C);
> printf("DlyC: "+DlyClose +"\n");//////////////////////////////
> //Now calculate the min range value using Open, Low and High
> //variables calculated above
> RngMin = Min(DlyHighest - MrktOpen, MrktOpen - DlyLowest);
> //Compres this to a daily time frame in order to capture
> //the final value of the Range Min for each trading day
> DlyRngMin = TimeFrameCompress(RngMin, inDaily, compressLast);
> //Use the compressed variable to calculate a 10 day average\
> RngMinAvg = MA(DlyRngMin , 10);
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/