|
//+------------------------------------------------------------------+
//| Slope.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#define SIGNAL_BAR 1
#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//http://articles.mql4.com/374
//+------------------------------------------------------------------+
extern int Ma_period=60;
extern int RangeValue=5;
double Slopebuffer[];
double Mabuffer[];
double prevbuffer[];
int init()
{
//---- indicators
IndicatorBuffers(3);
SetIndexBuffer(0,Slopebuffer);
SetIndexStyle(0,1,EMPTY,2,DarkGreen);
SetIndexBuffer(1,Mabuffer);
SetIndexBuffer(2,prevbuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit;
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
static int PrevSignal = 0, PrevTime = 0;
for(int i = 0; i < limit; i++)
{
Mabuffer=iMA(NULL,0,Ma_period,0,MODE_SMA,PRICE_CLOSE,i);
// Slopebuffer=(Mabuffer-Mabuffer[i+1])/0.0001;
}
for(i = 0; i < limit; i++)
{
Slopebuffer=(Mabuffer-Mabuffer[i+1])/0.0001;
/*if(i>1 && count<=4)
{
if(Slopebuffer*Slopebuffer[i-1]<=0 )
{
prevbuff[count-1]=i;
if(MathAbs(prevbuff[count-1]-prevbuff[count])<=8)
{
prevbuff[count-1]=prevbuff[count];
}
else
{
count++;
}
}
}*/
}
/*
int count=0;
/*
for(i=0;i<limit;i++)
{
if(Slopebuffer*Slopebuffer[i+1]<0 && count<=5 )
{
prevbuffer[count]=i+1;
if(count >=1 && MathAbs(prevbuffer[count]-prevbuffer[count-1])<=RangeValue)
{
prevbuffer[count-1]=prevbuffer[count];
count--;
}
count++;
}
}
while(count<=4)
{
count++;
}
Print(" "+prevbuffer[0]+" "+prevbuffer[1]+" "+prevbuffer[2]+" "+prevbuffer[3]+" ");
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime)
return(0);
PrevTime = Time[0];*/
//----
//get previous 3 points,High,Low
//---
/* if(Slopebuffer[SIGNAL_BAR]*Slopebuffer[SIGNAL_BAR+1]<=0 && revSignal!=1)
{
PrevSignal=1;
//judge up or down
if(Slopebuffer[1]>=0 && Slopebuffer[2]<0)
{
//check previous 3 point
Alert(Symbol()+","+Period()+",up");
}
if(Slopebuffer[1]<=0 && Slopebuffer[2]>0)
{
Alert(Symbol()+","+Period()+",down");
}
}
if(Slopebuffer[SIGNAL_BAR]*Slopebuffer[SIGNAL_BAR+1]>0 && revSignal!=0)
{
PrevSignal=0;
}
*/
//----
return(0);
}
//+------------------------------------------------------------------+[/code]
这是代码,看下,我就知道几个html, |
|