|
本帖最后由 霸王孤影 于 2022-4-12 16:29 编辑
修改后的可以切换周期了
//+------------------------------------------------ ------------------+
//| 坡度.mq4 |
//| 版权所有?2011,MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------ ------------------+
#property 版权所有“版权所有?2011,MetaQuotes Software Corp.”
#property 链接“http://www.metaquotes.net”
#define SIGNAL_BAR 1
#property indicator_separate_window
//+------------------------------------------------ ------------------+
//| 自定义指标初始化函数 |
//http://articles.mql4.com/374
//+------------------------------------------------ ------------------+
extern int Ma_period=60;
外部 int RangeValue=5;
双斜率缓冲区[];
双 Mabuffer[];
双 prevbuffer[];
初始化初始化()
{
//---- 指标
指标缓冲区(3);
SetIndexBuffer(0,Slopebuffer);
SetIndexStyle(0,1,EMPTY,2,DarkGreen);
SetIndexBuffer(1,Mabuffer);
SetIndexBuffer(2,prevbuffer);
//----
返回(0);
}
//+------------------------------------------------ ------------------+
//| 自定义指标去初始化函数 |
//+------------------------------------------------ ------------------+
int deinit()
{
//----
//----
返回(0);
}
//+------------------------------------------------ ------------------+
//| 自定义指标迭代函数 |
//+------------------------------------------------ ------------------+
整数开始()
{
int counted_bars=IndicatorCounted();
整数限制;
如果(counted_bars > 0)
counted_bars——;
limit = Bars - counted_bars;
静态int PrevSignal = 0,PrevTime = 0;
for(int i = 0; i < 限制; i++)
{
//Mabuffer=iMA(NULL,PERIOD_H4,Ma_period,0,MODE_SMA,PRICE_CLOSE,i);
Mabuffer=iMA(NULL,0,Ma_period,0,MODE_SMA,PRICE_CLOSE,i);
// Slopebuffer=(Mabuffer-Mabuffer[i+1])/0.0001;
}
for(i = 0; i < 限制; i++)
{
斜率缓冲区=(Mabuffer-Mabuffer[i+1])/0.0001;
/*if(i>1 && 计数<=4)
{
如果(坡度缓冲区*坡度缓冲区[i-1]<=0)
{
prevbuff[count-1]=i;
if(MathAbs(prevbuff[count-1]-prevbuff[count])<=8)
{
prevbuff[count-1]=prevbuff[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];
数数 - ;
}
计数++;
}
}
而(计数<=4)
{
计数++;
}
打印(""+prevbuffer[0]+""+prevbuffer[1]+""+prevbuffer[2]+""+prevbuffer[3]+"");
if(SIGNAL_BAR > 0 && Time[0] <= PrevTime)
返回(0);
PrevTime = 时间[0];*/
//----
//获取前3个点,高,低
//---
/* if(Slopebuffer[SIGNAL_BAR]*Slopebuffer[SIGNAL_BAR+1]<=0 &&PrevSignal!=1)
{
上一个信号=1;
//判断向上或向下
if(斜率缓冲区[1]>=0 && 斜率缓冲区[2]<0)
{
//检查前3点
警报(符号()+","+句号()+",up");
}
if(斜率缓冲区[1]<=0 && 斜率缓冲区[2]>0)
{
警报(Symbol()+","+Period()+",down");
}
}
if(Slopebuffer[SIGNAL_BAR]*Slopebuffer[SIGNAL_BAR+1]>0 &&PrevSignal!=0)
{
上一个信号=0;
}
*/
//----
返回(0);
}
//+------------------------------------------------ -------------------+[/code] |
|