79 lines
No EOL
2.7 KiB
MQL4
79 lines
No EOL
2.7 KiB
MQL4
//+------------------------------------------------------------------+
|
|
//| KG Average HLCC.mq4 |
|
|
//| Copyright © 2008, MetaQuotes Software Corp. |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright © 2008, Goen"
|
|
#property link "http://www.forexindo.com/forum/showthread.php?t=95"
|
|
|
|
#property indicator_chart_window
|
|
#property indicator_buffers 3
|
|
#property indicator_color1 Aqua
|
|
#property indicator_color2 Magenta
|
|
#property indicator_color3 Lime
|
|
|
|
//---- buffers
|
|
double AverageMonth[];
|
|
double AverageWeek[];
|
|
double AverageDay[];
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Custom indicator initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int init()
|
|
{
|
|
SetIndexStyle(0,DRAW_LINE,0,2);
|
|
SetIndexBuffer(0,AverageMonth);
|
|
SetIndexLabel(0,"Average Month");
|
|
SetIndexStyle(1,DRAW_LINE,0,2);
|
|
SetIndexBuffer(1,AverageWeek);
|
|
SetIndexLabel(1,"Average Week");
|
|
SetIndexStyle(2,DRAW_LINE,0,2);
|
|
SetIndexBuffer(2,AverageDay);
|
|
SetIndexLabel(2,"Average Day");
|
|
IndicatorShortName("KG Average HLCC,");
|
|
}
|
|
//----
|
|
//return(0);
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MTF Moving Average |
|
|
//+------------------------------------------------------------------+
|
|
int start()
|
|
{
|
|
datetime TimeArray[];
|
|
int i,shift,limit,y=0,counted_bars=IndicatorCounted();
|
|
|
|
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),43200);
|
|
limit=Bars-counted_bars+43200/Period();
|
|
for(i=0,y=0;i<limit;i++)
|
|
{
|
|
if (Time[i]<TimeArray[y]) y++;
|
|
AverageMonth[i]= (iHigh(NULL,PERIOD_MN1,y+1) + iLow(NULL,PERIOD_MN1,y+1) +
|
|
iClose(NULL,PERIOD_MN1,y+1) + iClose(NULL,PERIOD_MN1,y+1))/4;
|
|
}
|
|
|
|
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),10080);
|
|
limit=Bars-counted_bars+10080/Period();
|
|
for(i=0,y=0;i<limit;i++)
|
|
{
|
|
if (Time[i]<TimeArray[y]) y++;
|
|
AverageWeek[i] = (iHigh(NULL,PERIOD_W1,y+1) + iLow(NULL,PERIOD_W1,y+1) +
|
|
iClose(NULL,PERIOD_W1,y+1) + iClose(NULL,PERIOD_W1,y+1))/4;
|
|
}
|
|
|
|
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),1440);
|
|
limit=Bars-counted_bars+1440/Period();
|
|
for(i=0,y=0;i<limit;i++)
|
|
{
|
|
if (Time[i]<TimeArray[y]) y++;
|
|
AverageDay[i] = (iHigh(NULL,PERIOD_D1,y+1) + iLow(NULL,PERIOD_D1,y+1) +
|
|
iClose(NULL,PERIOD_D1,y+1) + iClose(NULL,PERIOD_D1,y+1))/4;
|
|
}
|
|
|
|
//
|
|
|
|
|
|
|
|
return(0);
|
|
}
|
|
//+------------------------------------------------------------------+ |