顺水外汇EA交易网MT4
标题:
谁有mt4自带的stoch 就是俗称kdj的源码啊?
[打印本页]
作者:
kadajlgc
时间:
2018-1-11 16:44
标题:
谁有mt4自带的stoch 就是俗称kdj的源码啊?
谁有mt4自带的stoch 就是俗称kdj的源码啊?
我想用来改一下 求共享啊
作者:
林雁
时间:
2018-1-11 16:52
Stochastic Oscillator指标 原码
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
//---- input parameters
extern int KPeriod=5;
extern int DPeriod=3;
extern int Slowing=3;
//---- buffers
double MainBuffer[];
double SignalBuffer[];
double HighesBuffer[];
double LowesBuffer[];
//----
int draw_begin1=0;
int draw_begin2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(4);
SetIndexBuffer(2, HighesBuffer);
SetIndexBuffer(3, LowesBuffer);
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, MainBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, SignalBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="Sto("+KPeriod+","+DPeriod+","+Slowing+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"Signal");
//----
draw_begin1=KPeriod+Slowing;
draw_begin2=draw_begin1+DPeriod;
SetIndexDrawBegin(0,draw_begin1);
SetIndexDrawBegin(1,draw_begin2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Stochastic oscillator |
//+------------------------------------------------------------------+
int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double price;
//----
if(BarsKPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double min=1000000;
k=i+KPeriod-1;
while(k>=i)
{
price=Low[k];
if(min>price) min=price;
k--;
}
LowesBuffer=min;
i--;
}
//---- maximums counting
i=Bars-KPeriod;
if(counted_bars>KPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double max=-1000000;
k=i+KPeriod-1;
while(k>=i)
{
price=High[k];
if(maxdraw_begin1) i=Bars-counted_bars-1;
while(i>=0)
{
double sumlow=0.0;
double sumhigh=0.0;
for(k=(i+Slowing-1);k>=i;k--)
{
sumlow+=Close[k]-LowesBuffer[k];
sumhigh+=HighesBuffer[k]-LowesBuffer[k];
}
if(sumhigh==0.0) MainBuffer=100.0;
else MainBuffer=sumlow/sumhigh*100;
i--;
}
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
//---- signal line is simple movimg average
for(i=0; i纯文本查看 复制代码//+------------------------------------------------------------------+
//| Stochastic.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Stochastic Oscillator"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
#property indicator_level1 20.0
#property indicator_level2 80.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameters
input int InpKPeriod=5; // K Period
input int InpDPeriod=3; // D Period
input int InpSlowing=3; // Slowing
//--- buffers
double ExtMainBuffer[];
double ExtSignalBuffer[];
double ExtHighesBuffer[];
double ExtLowesBuffer[];
//---
int draw_begin1=0;
int draw_begin2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
string short_name;
//--- 2 additional buffers are used for counting.
IndicatorBuffers(4);
SetIndexBuffer(2, ExtHighesBuffer);
SetIndexBuffer(3, ExtLowesBuffer);
//--- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ExtMainBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
short_name="Sto("+IntegerToString(InpKPeriod)+","+IntegerToString(InpDPeriod)+","+IntegerToString(InpSlowing)+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"Signal");
//---
draw_begin1=InpKPeriod+InpSlowing;
draw_begin2=draw_begin1+InpDPeriod;
SetIndexDrawBegin(0,draw_begin1);
SetIndexDrawBegin(1,draw_begin2);
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Stochastic oscillator |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int i,k,pos;
//--- check for bars count
if(rates_totallow[k])
dmin=low[k];
if(dmax<high[k])
dmax=high[k];
}
ExtLowesBuffer[i]=dmin;
ExtHighesBuffer[i]=dmax;
}
//--- %K line
pos=InpKPeriod-1+InpSlowing-1;
if(pos+1<prev_calculated)
pos=prev_calculated-2;
else
{
for(i=0; i<pos; i++)
ExtMainBuffer[i]=0.0;
}
//--- main cycle
for(i=pos; i<rates_total && !IsStopped(); i++)
{
double sumlow=0.0;
double sumhigh=0.0;
for(k=(i-InpSlowing+1); k<=i; k++)
{
sumlow +=(close[k]-ExtLowesBuffer[k]);
sumhigh+=(ExtHighesBuffer[k]-ExtLowesBuffer[k]);
}
if(sumhigh==0.0)
ExtMainBuffer[i]=100.0;
else
ExtMainBuffer[i]=sumlow/sumhigh*100.0;
}
//--- signal
pos=InpDPeriod-1;
if(pos+1<prev_calculated)
pos=prev_calculated-2;
else
{
for(i=0; i<pos; i++)
ExtSignalBuffer[i]=0.0;
}
for(i=pos; i<rates_total && !IsStopped(); i++)
{
double sum=0.0;
for(k=0; k[I]
作者:
八月未央
时间:
2018-1-11 17:46
记得这个在mt4的文件夹里面不是有的吗?Stochastic.mq4
作者:
kadajlgc
时间:
2018-1-11 19:07
我是来学习的
作者:
digit
时间:
2018-1-11 20:38
感谢分享
作者:
flinkor
时间:
2018-1-11 22:10
看看看下下
[attach]22821[/attach]
[attach]22822[/attach]
作者:
dblyww
时间:
2018-1-11 23:36
谢谢分享
作者:
sievakigson
时间:
2018-1-12 01:01
谢谢分享
作者:
shejin
时间:
2018-1-12 02:35
非常需要,谢谢楼主分享了!!
作者:
15434171
时间:
2018-1-12 03:51
编译不了 代码有错误
作者:
永痕
时间:
2018-1-12 03:59
谢谢分享,学编程,学交易,实现程序化交易。
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2