顺水外汇EA交易网MT4
标题:
请牛版帮助修改1H周期显示4H周期
[打印本页]
作者:
呆子off
时间:
2018-1-11 18:19
标题:
请牛版帮助修改1H周期显示4H周期
//+------------------------------------------------------------------+
//| Schaff Trend Cycle.mq4 |
//| mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 Green
//
//
//
//
//
extern int STCPeriod = 10;
extern int FastMAPeriod = 23;
extern int SlowMAPeriod = 50;
//
//
//
//
//
double stcBuffer[];
double stcBufferUA[];
double stcBufferUB[];
double macdBuffer[];
double fastKBuffer[];
double fastDBuffer[];
double fastKKBuffer[];
double trend[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int init()
{
IndicatorBuffers(8);
SetIndexBuffer(0,stcBuffer);
SetIndexBuffer(1,stcBufferUA);
SetIndexBuffer(2,stcBufferUB);
SetIndexBuffer(3,macdBuffer);
SetIndexBuffer(4,fastKBuffer);
SetIndexBuffer(5,fastDBuffer);
SetIndexBuffer(6,fastKKBuffer);
SetIndexBuffer(7,trend);
IndicatorShortName("Schaff Trend Cycle ("+STCPeriod+","+FastMAPeriod+","+SlowMAPeriod+")");
return(0);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
if(counted_bars 0) counted_bars--;
limit = Bars-counted_bars;
if (trend[limit]==1) CleanPoint(limit,stcBufferUA,stcBufferUB);
//
//
//
//
//
for(i = limit; i >= 0; i--)
{
macdBuffer
= iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_CLOSE,i)-
iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_CLOSE,i);
//
//
//
//
//
double lowMacd = minValue(macdBuffer,i);
double highMacd = maxValue(macdBuffer,i)-lowMacd;
if (highMacd > 0)
fastKBuffer
= 100*((macdBuffer
-lowMacd)/highMacd);
else fastKBuffer
= fastKBuffer[i+1];
fastDBuffer
= fastDBuffer[i+1]+0.5*(fastKBuffer
-fastDBuffer[i+1]);
//
//
//
//
//
double lowStoch = minValue(fastDBuffer,i);
double highStoch = maxValue(fastDBuffer,i)-lowStoch;
if (highStoch > 0)
fastKKBuffer
= 100*((fastDBuffer
-lowStoch)/highStoch);
else fastKKBuffer
= fastKKBuffer[i+1];
stcBuffer
= stcBuffer[i+1]+0.5*(fastKKBuffer
-stcBuffer[i+1]);
//
//
//
//
//
trend
=trend[i+1];
stcBufferUA
= EMPTY_VALUE;
stcBufferUB
= EMPTY_VALUE;
if (stcBuffer
> stcBuffer[i+1]) trend
= 1;
if (stcBuffer
< stcBuffer[i+1]) trend
=-1;
if (trend
== 1) PlotPoint(i,stcBufferUA,stcBufferUB,stcBuffer);
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
double minValue(double& array[],int shift)
{
double minValue = array[shift];
for (int i=1; i<STCPeriod; i++) minValue = MathMin(minValue,array[shift+i]);
return(minValue);
}
double maxValue(double& array[],int shift)
{
double maxValue = array[shift];
for (int i=1; i<STCPeriod; i++) maxValue = MathMax(maxValue,array[shift+i]);
return(maxValue);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
void CleanPoint(int i,double& first[],double& second[])
{
if ((second
!= EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE))
second[i+1] = EMPTY_VALUE;
else
if ((first
!= EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE))
first[i+1] = EMPTY_VALUE;
}
//
//
//
//
//
void PlotPoint(int i,double& first[],double& second[],double& from[])
{
if (first[i+1] == EMPTY_VALUE)
{
if (first[i+2] == EMPTY_VALUE) {
first
= from
;
first[i+1] = from[i+1];
second
= EMPTY_VALUE;
}
else {
second
= from
;
second[i+1] = from[i+1];
first
= EMPTY_VALUE;
}
}
else
{
first
= from
;
second
= EMPTY_VALUE;
}
}
作者:
metatrade
时间:
2018-1-11 19:41
自己把参数值改一下就好了
extern int STCPeriod = 10;
extern int FastMAPeriod = 23;
extern int SlowMAPeriod = 50;
double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
计算移动平均指标并返回它的值。
参量:
symbol - 计算指标数据上的货币对名称. NULL表示当前货币对.
timeframe - 时间周期。 可以时间周期列举任意值. 0表示当前图表的时间周期.
period - 平均周期计算。
ma_shift - MA转移。 指标线垂直与图表的时间周期.
ma_method - MA方法。 它可以是其中任意 滑动平均值列举 值.
作者:
带翅膀黄金
时间:
2018-1-11 20:47
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
作者:
呆子off
时间:
2018-1-11 22:16
已经试过了 时间周期已经更改为240 但是显示会错误。
作者:
bls02dr
时间:
2018-1-11 23:02
了解一下
作者:
jason_den
时间:
2018-1-11 23:08
好好学习天天向上
作者:
forex995
时间:
2018-1-11 23:36
謝謝,不錯,學習囉
作者:
362574828
时间:
2018-1-12 00:43
改一下就好了
作者:
待续...
时间:
2018-1-12 01:27
回复赚金币
作者:
jiahu
时间:
2018-1-12 02:32
謝謝,不錯,學習囉
作者:
dipeng741
时间:
2018-1-12 02:45
谢谢分享
作者:
itpingtai
时间:
2018-1-12 03:03
学习一下
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2