David says
 
I am not sure what you consider to be "Average" but the following 
will provide the average (H+L+C)/3 for Daily and Hourly time frames. 
The AFL is for written for setting the time frame to daily and hourly 
for intraday data.

Regards,

CODING BY David K.
==================================================
TimeFrameSet( inDaily);
AVGd = Ref((L + H + C),-1)/3;
" PPd:\t "+ AVGd;
TimeFrameRestore( );
Plot( TimeFrameExpand
(AVGd,inDaily, expandFirst) ,"",41,styleStai rcase|styleNoLab el,0,0,2) ;

TimeFrameSet( inHourly) ;
AVGh = Ref((L + H + C),-1)/3;
" PPh:\t "+ Avgh;
TimeFrameRestore( );
Plot( TimeFrameExpand
(AVGh,inHourly, expandFirst) ,"",41,styleStai rcase|styleNoLab el,0,0,2) ;
===============================================
 
THOMAS  says
the code should do what you need.
===============================
DayChange = Day() != Ref(Day(), -1);
AvgTradePrice = Null;
CurDayBars = 0;
CurDayCloseSum = 0;

for (i = 0; i < BarCount; i++)
{
        if (DayChange[i])
        {
                CurDayCloseSum = C[i];
                CurDayBars = 1;
        }
        else
        {
                CurDayCloseSum = CurDayCloseSum + C[i];
                CurDayBars++;           
        }
        AvgTradePrice[i] = CurDayCloseSum / CurDayBars; 
}

Plot(AvgTradePrice, "AvgTradePrice", 4, 1);
PlotShapes(shapeCircle * DayChange, colorBlue, 0, C, 0);
========================================
Coding by  Thomas- www.PatternExplorer.com

Try these and find out how brokers calculate ATP,like indiainfoline etc.
 
Hope it helps
rv
--- On Tue, 6/22/10, Deepak Patade <[email protected]> wrote:


From: Deepak Patade <[email protected]>
Subject: [amibroker] average traded price
To: [email protected]
Cc: [email protected]
Date: Tuesday, June 22, 2010, 11:51 AM


  






How to write the afl line to calculate the average traded price of the stock.
 Deepak Patade 









      

Reply via email to