心和尚 发表于 2012-11-30 10:54:32

某朋友要的LW%R指标

指标是LW%R

//+------------------------------------------------------------------+
//| LW%R.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window

#property indicator_buffers 2
#property indicator_color1 Silver
#property indicator_color2 Yellow


//---- input parameters
extern int NPeriod=9;
extern int KPeriod=3;
extern int SKPeriod=3;
extern int SDPeriod=3;

double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
double ind_buffer4[];
double ind_buffer5[];
double HighesBuffer[];
double LowesBuffer[];

int draw_begin1=0;
int draw_begin2=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(7);
SetIndexBuffer(0, ind_buffer3);
SetIndexBuffer(1, ind_buffer4);
SetIndexBuffer(2, ind_buffer1);
SetIndexBuffer(3, ind_buffer2);
SetIndexBuffer(4, HighesBuffer);
SetIndexBuffer(5, LowesBuffer);
SetIndexBuffer(6, ind_buffer5);


//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ind_buffer3);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ind_buffer4);

//---- name for DataWindow and indicator subwindow label
IndicatorShortName("LW%R("+NPeriod+","+KPeriod+","+SKPeriod+","+SDPeriod+")");
SetIndexLabel(0,"K");
SetIndexLabel(1,"D");

//----
draw_begin1=NPeriod+SKPeriod;
draw_begin2=draw_begin1+KPeriod;
SetIndexDrawBegin(0,draw_begin1);
SetIndexDrawBegin(1,draw_begin2);
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double price;
//----
if(Bars<=draw_begin2) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=draw_begin1;i++) ind_buffer1=0;
for(i=1;i<=draw_begin2;i++) ind_buffer2=0;
}
//---- minimums counting
i=Bars-NPeriod;
if(counted_bars>NPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double min=1000000;
k=i+NPeriod-1;
while(k>=i)
{
price=Low;
if(min>price) min=price;
k--;
}
LowesBuffer=min;
i--;
}
//---- maximums counting
i=Bars-NPeriod;
if(counted_bars>NPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double max=-1000000;
k=i+NPeriod-1;
while(k>=i)
{
price=High;
if(max<price) max=price;
k--;
}
HighesBuffer=max;
i--;
}
//---- %K line
i=Bars-draw_begin1;
if(counted_bars>draw_begin1) i=Bars-counted_bars-1;
while(i>=0)
{
double sumlow=0.0;
double sumhigh=0.0;
for(k=(i+SKPeriod-1);k>=i;k--)
{
sumlow+=Close-LowesBuffer;
sumhigh+=HighesBuffer-LowesBuffer;
}
if(sumhigh==0.0) ind_buffer1=100.0;
else ind_buffer1=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<limit; i++)
ind_buffer2=iMAOnArray(ind_buffer1,Bars,KPeriod,0,MODE_SMA,i);
for(i=0; i<limit; i++)
{ind_buffer5=iMAOnArray(ind_buffer2,Bars,SKPeriod,0,MODE_SMA,i);
ind_buffer3=100-ind_buffer5;
}
for(i=0; i<limit; i++)
ind_buffer4=100-iMAOnArray(ind_buffer5,Bars,SDPeriod,0,MODE_SMA,i);

//----
return(0);
}
//+------------------------------------------------------------------+

李华 发表于 2012-12-2 19:40:59

真的有么

小妖精 发表于 2012-12-2 19:40:59

又看了一次

二元期权 发表于 2012-12-2 20:36:11

顶.支持,路过.....

nihaoya78 发表于 2012-12-2 20:36:11

加油啊!!!!顶哦!!!!!

fxsin8.7 发表于 2012-12-2 20:46:22

想了解加下Q吧绝对真实 OK   

全球天使 发表于 2013-4-18 19:26:08

hgfhgfhbgf

紫竹青荷 发表于 2013-5-21 11:36:55

看不懂。。。。。

若兰如风 发表于 2013-7-8 23:44:05

上官 发表于 2013-7-20 16:55:17

eterter
页: [1] 2 3 4 5
查看完整版本: 某朋友要的LW%R指标