fast-oscillator
//+------------------------------------------------------------------+
//| _Fast2.mq4 |
//| Copyright ?2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 LightSeaGreen
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_color5 Red
#property indicator_color6 Blue
extern int ma1=3;
extern int ma2=9;
extern bool sound=true;
extern bool alert=false;
extern bool comment=true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double Outbuf[];
static int prevtime = 0 ;
double spr,stop;
string simv;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,0,2);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_NONE);
SetIndexBuffer(3,Outbuf);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,236);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexEmptyValue(4,0.0);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,238);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexEmptyValue(5,0.0);
//----
Outbuf=0;
simv = (Symbol());
if (simv == "EURUSD")
{
spr = MarketInfo("EURUSD",MODE_SPREAD);
stop = MarketInfo("EURUSD",MODE_STOPLEVEL);
}
if (simv == "GBPUSD")
{
spr = MarketInfo("GBPUSD",MODE_SPREAD);
stop = MarketInfo("GBPUSD",MODE_STOPLEVEL);
}
if (simv == "EURJPY")
{
spr = MarketInfo("EURJPY",MODE_SPREAD);
stop = MarketInfo("EURJPY",MODE_STOPLEVEL);
}
if (simv == "GBPJPY")
{
spr = MarketInfo("GBPJPY",MODE_SPREAD);
stop = MarketInfo("GBPJPY",MODE_STOPLEVEL);
}
if (simv == "USDJPY")
{
spr = MarketInfo("USDJPY",MODE_SPREAD);
stop = MarketInfo("USDJPY",MODE_STOPLEVEL);
}
if (simv == "EURCHF")
{
spr = MarketInfo("EURCHF",MODE_SPREAD);
stop = MarketInfo("EURCHF",MODE_STOPLEVEL);
}
if (simv == "GBPCHF")
{
spr = MarketInfo("GBPCHF",MODE_SPREAD);
stop = MarketInfo("GBPCHF",MODE_STOPLEVEL);
}
if (simv == "USDCHF")
{
spr = MarketInfo("USDCHF",MODE_SPREAD);
stop = MarketInfo("USDCHF",MODE_STOPLEVEL);
}
if (simv == "USDCAD")
{
spr = MarketInfo("USDCAD",MODE_SPREAD);
stop = MarketInfo("USDCAD",MODE_STOPLEVEL);
}
if (simv == "AUDUSD")
{
spr = MarketInfo("AUDUSD",MODE_SPREAD);
stop = MarketInfo("AUDUSD",MODE_STOPLEVEL);
}
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int counted_bars=IndicatorCounted();
//----
if(counted_bars>0)
counted_bars--;
int limit=Bars-counted_bars;
for(int i=0;i<Bars;i++)
{
ExtMapBuffer1=((Close-Open)+((Close-Open)/MathSqrt(2))+((Close-Open)/MathSqrt(3)))/Point;
// ExtMapBuffer1=((Close-Open)+((Close-Open)/MathSqrt(2))+((Close-Open)/MathSqrt(3))+((Close-Open)/MathSqrt(5))+((Close-Open)/MathSqrt(8)))/Point;
}
for(i=0;i<Bars;i++)
{
ExtMapBuffer2=iMAOnArray(ExtMapBuffer1,Bars,ma1,0,MODE_LWMA,i);
ExtMapBuffer3=iMAOnArray(ExtMapBuffer1,Bars,ma2,0,MODE_LWMA,i);
}
// 其屐, 觐沅?耵铕扈痼弪? 眍恹?徉?
if (Time == prevtime) return(0);
prevtime = Time;
Outbuf=0;
//--------------------
if (((ExtMapBuffer2 > ExtMapBuffer3)&&(ExtMapBuffer2 < ExtMapBuffer3)&&(ExtMapBuffer2 < ExtMapBuffer3))
&&((ExtMapBuffer2>0)&&(ExtMapBuffer3>0))&&((ExtMapBuffer1<=0)&&(ExtMapBuffer1<0)))
{
ExtMapBuffer6=(ExtMapBuffer1+ExtMapBuffer2);
if (sound==true)PlaySound("alert.wav");
if (alert==true) Alert (Symbol());
if (comment==true)Comment(Symbol(),TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","SELL SL= ",MathAbs(ExtMapBuffer1-Close));
Outbuf=1;
Outbuf=(MathAbs(ExtMapBuffer1-Close));
if (Outbuf<stop) Outbuf =(MathAbs(ExtMapBuffer1-Close))+ stop;
} else { ExtMapBuffer6= 0.0; }
if (((ExtMapBuffer2 < ExtMapBuffer3)&&(ExtMapBuffer2 > ExtMapBuffer3)&&(ExtMapBuffer2 > ExtMapBuffer3))
&&((ExtMapBuffer2<0)&&(ExtMapBuffer3<0))&&((ExtMapBuffer1>=0)&&(ExtMapBuffer1>0)))
{
ExtMapBuffer5=(ExtMapBuffer1+ExtMapBuffer2);
if (sound==true)PlaySound("alert.wav");
if (alert==true) Alert (Symbol());
if (comment==true)Comment(Symbol(),TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","BUY SL= ",MathAbs(ExtMapBuffer1-Close));
Outbuf=2;
Outbuf=(MathAbs(ExtMapBuffer1-Close));
if (Outbuf<stop) Outbuf=(MathAbs(ExtMapBuffer1-Close))+ stop;
} else {ExtMapBuffer5= 0.0;}
if ((ExtMapBuffer2 - ExtMapBuffer3) > (ExtMapBuffer2 - ExtMapBuffer3))
{
if (sound==true)PlaySound("alert2.wav");
if (comment==true)Comment(TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS),"\n","Close !!!",(Close));
Outbuf=3;
}
//----
return(0);
}
//+------------------------------------------------------------------+
帮你顶下哈!! 不错,支持下楼主 不错不错,很好哦 我抢、我抢、我抢沙发~ 小手一抖,积分到手! 学习了,不错 谢谢楼主分享 {:1_186:}
页:
[1]