[MT4指标]KasePeakOscilator-KPO指标
附图指标,
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//| KasePeakOscilator_v1.mq4 |
//| Kalenzo |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "[email protected]"
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Yellow
extern int KPeriod = 30;
extern int BarsToCalculate = 300;
double RWHL;
double Pk;
double PkGreen;
double PkRed;
double MN;
double SD;
double v1,v2;
double Line;
#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,1);
SetIndexBuffer(0,PkGreen);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,1);
SetIndexBuffer(1,PkRed);
SetIndexStyle(2,DRAW_LINE,EMPTY,1);
SetIndexBuffer(2,Line);
SetIndexBuffer(3,RWHL);
SetIndexBuffer(4,MN);
SetIndexBuffer(5,SD);
SetIndexBuffer(6,Pk);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int limit = BarsToCalculate;
//----
for(int i = 0; i <= limit; i++)
{
double H = (High-Low[i+KPeriod])/(iATR(Symbol(),0,KPeriod,i)*MathSqrt(KPeriod));
double L = (High[i+KPeriod]-Low)/(iATR(Symbol(),0,KPeriod,i)*MathSqrt(KPeriod));
RWHL = H - L;
}
for(int p = 0; p <= limit; p++) Pk = iMAOnArray(RWHL,0,3,0,MODE_LWMA,p);
for(int m = 0; m <= limit; m++) MN[m] = iMAOnArray(Pk,0,KPeriod,0,MODE_SMA,m);
for(int s = 0; s <= limit; s++) SD[s] = iStdDevOnArray(Pk,0,KPeriod,MODE_SMA,0,s);
for(int v = 0; v <= limit; v++)
{
if(MN[v]+(1.33*SD[v])>2.08)
v1 = MN[v]+(1.33*SD[v]);
else
v1 = 2.08;
if(MN[v]-(1.33*SD[v])<-1.92)
v2 = MN[v]-(1.33*SD[v]);
else
v2 = -1.92;
if(Pk[v+1]>Pk[v])
{
PkRed[v] = Pk[v];
PkGreen[v] = 0;
}
else
{
PkRed[v] = 0;
PkGreen[v] = Pk[v];
}
if(Pk[v+1] >= 0 && Pk[v] > 0)
{
Line[v] = v1;
}
else
{
if(Pk[v+1] <= 0 && Pk[v] < 0)
{
Line[v] = v2;
}
else
{
Line[v] = 0;
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+
//| Kanal_Ant.mq4 |
//| Copyright ? 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//| red. Stajer59, http://www.stajer59.ucoz.ru |
//| (orig.: Envelopes.mq4) |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Blue
#property indicator_color6 Red
#property indicator_color7 Teal
//---- indicator parameters
extern int BarsCount = 500;
extern int MA_Period=55;
extern int MA_Shift=0;
extern int MA_Method=0;
extern int Applied_Price=0;
extern int fontsize=7;
extern double Deviation=1;
//---- indicator buffers
double ExtMapBuffer1;
double ExtMapBuffer2;
double ExtMapBuffer3;
double ExtMapBuffer4;
double ExtMapBuffer5;
double ExtMapBuffer6;
double ExtMapBuffer7;
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE,OBJPROP_WIDTH,2);
SetIndexStyle(5,DRAW_LINE,OBJPROP_WIDTH,2);
SetIndexStyle(6,DRAW_LINE,OBJPROP_WIDTH,2);
SetIndexShift(0,MA_Shift);
SetIndexShift(1,MA_Shift);
SetIndexShift(2,MA_Shift);
SetIndexShift(3,MA_Shift);
SetIndexShift(4,MA_Shift);
SetIndexShift(5,MA_Shift);
SetIndexShift(6,MA_Shift);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
if(MA_Period<2) MA_Period=14;
draw_begin=MA_Period-1;
//---- indicator short name
IndicatorShortName("Env("+MA_Period+")");
SetIndexLabel(0,"Env("+MA_Period+")U1");
SetIndexLabel(1,"Env("+MA_Period+")D1");
SetIndexLabel(2,"Env("+MA_Period+")U2");
SetIndexLabel(3,"Env("+MA_Period+")D2");
SetIndexLabel(4,"Env("+MA_Period+")U3");
SetIndexLabel(5,"Env("+MA_Period+")D3");
SetIndexLabel(6,"MA("+MA_Period+")");
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
SetIndexDrawBegin(2,draw_begin);
SetIndexDrawBegin(3,draw_begin);
SetIndexDrawBegin(4,draw_begin);
SetIndexDrawBegin(5,draw_begin);
SetIndexDrawBegin(6,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexBuffer(6,ExtMapBuffer7);
ObjectCreate("l1", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l1", "U1",fontsize,"Arial",Blue);
ObjectCreate("l2", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l2", "D1",fontsize,"Arial",Red);
ObjectCreate("l3", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l3", "U2",fontsize,"Arial",Blue);
ObjectCreate("l4", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l4", "D2",fontsize,"Arial",Red);
ObjectCreate("l5", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l5", "U3",fontsize,"Arial",Blue);
ObjectCreate("l6", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l6", "D3",fontsize,"Arial",Red);
ObjectCreate("l7", OBJ_TEXT, 0, 0, 0);
ObjectSetText("l7", "LB",fontsize,"Arial",Teal);
if(Deviation<0.1) Deviation=0.1;
if(Deviation>100.0) Deviation=100.0;
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("l1");
ObjectDelete("l2");
ObjectDelete("l3");
ObjectDelete("l4");
ObjectDelete("l5");
ObjectDelete("l6");
ObjectDelete("l7");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
if(Bars<=MA_Period) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
limit=Bars-ExtCountedBars;
//---- EnvelopesM counted in the buffers
for(int i=0; iKasePeakOscilator_v1.jpg
发表于:2017-08-11 08:49只看该作者
2楼
阅尽天下指标
韬客社区www.talkfx.co