求助,请帮忙在这条均线上加上报警
这是一条变色均线,希望各位大哥帮忙加个k现触碰到能报警,并加个标记指示,谢谢!MA_Color.mq4
发表于:2008-02-19 15:39只看该作者
2楼
是那均线SMA吗 帖张图吧
韬客社区www.talkfx.co
3楼
不知道是不是sma均线,我只是觉得这条线可以用得上,就是这条白蓝色的线,感觉不错
[ 本帖最后由 风精灵 于 2008-2-21 00:06 编辑 ]2.jpg
发表于:2008-02-21 04:34只看该作者
4楼
我看了一下,指标好象是WMA,
我抱歉,我只有SMA的穿越报警,是别人的指标,当然你稍加修改是可以满足你的要求的
其实我觉得如果真的有效就不用等到穿越再作单
韬客社区www.talkfx.co
发表于:2008-02-21 04:37只看该作者
5楼
//+------------------------------------------------------------------+
//| jump_over_ma.mq4 Ver. 1.1 |
//| 偶然帅 |
//| [email protected] |
//| Feb. 24, 2007 |
//| 价格上收于均线上方时发出声音报警信号。下收于均线下方也一样。 |
//| Feb. 26, 2007 在图表中显示信号。并提供均线周期等用户可修改的选 |
//| 项。升级到1.1版。 |
//+------------------------------------------------------------------+
#property copyright "偶然帅"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue // 信号的颜色;底为蓝色,顶为红色
#property indicator_color2 Red
extern int ma_period = 20; // 均线周期,默认值为20 bar均线
extern bool pop_up_alert = 0; // 弹出窗口报警,默认为关
extern bool sound_alert = 1; // 声音报警,默认为开
//---- buffers
double ExtMapBuffer1; // 显示信号用的缓冲区
double ExtMapBuffer2;
//+------------------------------------------------------------------+
//| 箭头初始化代码 |
//+------------------------------------------------------------------+
int init(){
SetIndexStyle(0,DRAW_ARROW,EMPTY,1); // 信号都用五角星表示
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexArrow(0,171);
SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexArrow(1,171);
return(0);
}
//+------------------------------------------------------------------+
//| 信号反初始化代码 |
//+------------------------------------------------------------------+
int deinit(){
return(0);
}
//+------------------------------------------------------------------+
//| 计算显示信号的条件 |
//+------------------------------------------------------------------+
int start(){
int i, shift;
double pos, pos_adjust, ma, prv_ma;
pos_adjust = 100*Point; // 根据不同的时间框架确定信号显示的位置。主要是为了美观
if(Period()==1) pos_adjust = 1*Point;
if(Period()==5) pos_adjust = 2*Point;
if(Period()==15) pos_adjust = 6*Point;
if(Period()==30) pos_adjust = 7*Point;
if(Period()==60) pos_adjust = 9*Point;
if(Period()==240) pos_adjust = 14*Point;
if(Period()==1440) pos_adjust = 35*Point;
shift=Bars;
for(i=shift-2;i>=0;i--){ // 从缓冲区中左起第二个bar开始显示,一直显示到右起第一个bar。
// 右起第一个bar的信号出现后,可能会消失;右起第二个bar以前的信号不变
ExtMapBuffer1=0;
ExtMapBuffer2=0;
// 使用SMA均线
ma = iMA( NULL, 0, ma_period, 0, MODE_SMA, PRICE_CLOSE, i);
prv_ma = iMA( NULL, 0, ma_period, 0, MODE_SMA, PRICE_CLOSE, i+1);
if(Close>ma && Close[i+1]prv_ma){
ExtMapBuffer2 = High + pos_adjust; // 做空信号
if(i==0 && pop_up_alert) Alert(Symbol(), ": 价格下收于均线");
if(i==0 && sound_alert) PlaySound("wait");
}
} // end of for(i=0
return(0);
}
//+------------------------------------------------------------------+
韬客社区www.talkfx.co
6楼
谢谢007的帮忙,可是这个不合用,谢谢,继续等
发表于:2008-03-04 12:17只看该作者
8楼
对源码作了适当修改,以提高程序可读性,并增加了报警语句,就是语句最后面这一段
if(mark!=1 && iClose(NULL,0,0)>ExtMapBuffer[0])
{Alert(Symbol(),"位于变色线上方"); mark=1;}
if(mark!=2 && iClose(NULL,0,0)[email protected]>, ?? ??????? ForexMagazine #104
//| [email protected]
//| Revised by IgorAD,[email protected] |
//|
//| Personalized by iGoR for the Trend Slope Trading method (T_S_T)
//| Link: http://www.strategybuilderfx.com/forums/showthread.php?t=16507
//| contact: [email protected]
//+------------------------------------------------------------------+
#property copyright "MT4 release WizardSerg <[email protected]>, ?? ??????? ForexMagazine #104"
#property link "[email protected]"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int period=15;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
double Uptrend; //上行数组
double nptrend; //下行数组
double ExtMapBuffer;
int mark=0;
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0, Uptrend);
SetIndexBuffer(1, nptrend);
SetIndexBuffer(2, ExtMapBuffer);
ArraySetAsSeries(ExtMapBuffer, true);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
IndicatorShortName("MegaTrend("+period+")");
return(0);
}
double WMA(int x, int p)
{ return(iMA(NULL, 0, p, 0, method, price, x)); }
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
int x = 0;
int p = MathSqrt(period);
int e = Bars - counted_bars + period + 1;
double vect, trend;
if(e > Bars) e = Bars;
ArrayResize(vect, e);
ArraySetAsSeries(vect, true);
ArrayResize(trend, e);
ArraySetAsSeries(trend, true);
for(x = 0; x < e; x++)
{ vect[x] = 2*WMA(x, period/2) - WMA(x, period); }
for(x = 0; x < e-period; x++)
ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);
for(x = e-period; x >= 0; x--)
{
if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) //指标线上行
{
Uptrend[x] = ExtMapBuffer[x];
Uptrend[x+1]=ExtMapBuffer[x+1];
nptrend[x] = EMPTY_VALUE; //下行线赋空值
}
else if(ExtMapBuffer[x]< ExtMapBuffer[x+1]) //指标线下行
{
nptrend[x] = ExtMapBuffer[x];
nptrend[x+1]=ExtMapBuffer[x+1];
Uptrend[x] = EMPTY_VALUE; //上行线赋空值
}
}
if(mark!=1 && iClose(NULL,0,0)>ExtMapBuffer[0])
{Alert(Symbol(),"位于变色线上方"); mark=1;}
if(mark!=2 && iClose(NULL,0,0)
9楼
实在非常非常感谢 秃鹫 老师 您的帮忙,谢谢,千万个谢谢!,我改动了一下报警方式,不敢独享,大家试用一下吧,好用的。
//+------------------------------------------------------------------+
//| MegaTrend HMA.mq4
//| Copyright ?2006 WizardSerg <[email protected]>, ?? ??????? ForexMagazine #104
//| [email protected]
//| Revised by IgorAD,[email protected] |
//|
//| Personalized by iGoR for the Trend Slope Trading method (T_S_T)
//| Link: http://www.strategybuilderfx.com/forums/showthread.php?t=16507
//| contact: [email protected]
//+------------------------------------------------------------------+
#property copyright "MT4 release WizardSerg <[email protected]>, ?? ??????? ForexMagazine #104"
#property link "[email protected]"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int period=15;
extern int method=3; // MODE_SMA
extern int price=0; // PRICE_CLOSE
extern bool VoiceAlert = false;
extern bool email = false;
double Uptrend; //上行数组
double nptrend; //下行数组
double ExtMapBuffer;
int alert;
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(0, Uptrend);
SetIndexBuffer(1, nptrend);
SetIndexBuffer(2, ExtMapBuffer);
ArraySetAsSeries(ExtMapBuffer, true);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
IndicatorShortName("MegaTrend("+period+")");
return(0);
}
double WMA(int x, int p)
{ return(iMA(NULL, 0, p, 0, method, price, x)); }
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
int x = 0;
int p = MathSqrt(period);
int e = Bars - counted_bars + period + 1;
double vect, trend;
if(e > Bars) e = Bars;
ArrayResize(vect, e);
ArraySetAsSeries(vect, true);
ArrayResize(trend, e);
ArraySetAsSeries(trend, true);
for(x = 0; x < e; x++)
{ vect[x] = 2*WMA(x, period/2) - WMA(x, period); }
for(x = 0; x < e-period; x++)
ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);
for(x = e-period; x >= 0; x--)
{
if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) //指标线上行
{
Uptrend[x] = ExtMapBuffer[x];
Uptrend[x+1]=ExtMapBuffer[x+1];
nptrend[x] = EMPTY_VALUE; //下行线赋空值
}
else if(ExtMapBuffer[x]< ExtMapBuffer[x+1]) //指标线下行
{
nptrend[x] = ExtMapBuffer[x];
nptrend[x+1]=ExtMapBuffer[x+1];
Uptrend[x] = EMPTY_VALUE; //上行线赋空值
}
}
if(alert!=1 && Close[0]>ExtMapBuffer[0] && Close[0]ExtMapBuffer[0]-10*Point && Close[1]>ExtMapBuffer[0])
{ if (VoiceAlert==true) {Alert(Symbol()+Period(),"下穿变色均线"); alert=2;}
if (email==true)
{SendMail(Symbol()+Period()+"****现价 :"+Close[0],"下穿变色均线"+"风精灵 , 祝你好运!");alert=2; } }
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 风精灵 于 2008-3-4 23:49 编辑 ]
发表于:2009-03-26 16:41只看该作者
10楼
没有钱了,灌个水
韬客社区www.talkfx.co
发表于:2009-04-25 16:17只看该作者
11楼
能不能改成均线交叉报警?
韬客社区www.talkfx.co