Скачать MetaTrader 5

Сглаженный стохастик

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Подключи MQL5 Cloud Network. Миллионы трейдеров ждут этого!
Forex Trader
114255
Forex Trader 2006.07.29 00:25 
Помогите, пожалуйста, перевести хороший индикатор с МТ3 на МТ4...



/*[[
Name := DS(q,r,s) - ïîâòîðíî ñãëàæåííûé ñòîõàñòèê
Author :=
Link :=
Separate Window := yes
First Color := Red
First Draw Type := Line
First Symbol := 217
Use Second Data := Yes
Second Color := LawnGreen
Second Draw Type := Line
Second Symbol := 218
]]*/
Input: qPeriod(13), rPeriod(32), EMAfast(5), CountBars(6000);
Variables : mtm(0),mtmInt(0), mtmIntPrev(0);
Variables : mtm1(0),mtmInt1(0), mtmIntPrev1(0);
Variables : DS_EMA(0),krPeriod(0),kEMAfast(0);
Variables : DS_EMAtopPrev(0), DS_EMAtop(0),DS_EMAbottomPrev(0), DS_EMAbottom(0);
Variables : cnt(0),shift(0),AccountedBars(0),firstTime(True);

If firstTime then
{
krPeriod=2/(rPeriod+1);
kEMAfast=2/(EMAfast+1);
AccountedBars = Bars-CountBars;
For shift = CountBars DownTo 0 Begin
SetIndexValue(shift, 0);
SetIndexValue2(shift, 0);
End;
firstTime=False;
};
mtmIntPrev=0; mtmIntPrev1=0; DS_EMAtopPrev=0;DS_EMAbottomPrev=0;
For cnt = AccountedBars To Bars Begin
shift = Bars - cnt;
mtm=Close[shift]-Low[Lowest(MODE_LOW,shift+qPeriod-1,qPeriod)];
If mtm=0 Then mtm=Point;
mtm1=High[Highest(MODE_HIGH,shift+qPeriod-1,qPeriod)]-
Low[Lowest(MODE_LOW,shift+qPeriod-1,qPeriod)];
If mtm1=0 Then mtm1=Point;
mtmInt=mtmIntPrev+krPeriod*(mtm-mtmIntPrev); // ÷èñëèòåëü ïðîèíòåãðèðîâàëè (1-å ñãëàæèâàíèå ïî r)
mtmInt1=mtmIntPrev1+krPeriod*(mtm1-mtmIntPrev1); // çíàìåíàòåëü ïðîèíòåãðèðîâàëè (1-å ñãëàæèâàíèå ïî r)
If shift=CountBars Then
{
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
Continue;
};
DS_EMAtop=DS_EMAtopPrev+kEMAfast*(mtmInt-DS_EMAtopPrev); // ñãëàäèëè èíòåãðàë ÷èñëèòåëÿ
DS_EMAbottom=DS_EMAbottomPrev+kEMAfast*(mtmInt1-DS_EMAbottomPrev); // ñãëàäèëè èíòåãðàë çíàìåíàòåëÿ
If shift=CountBars-1 Then
{
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
Continue;
};
DS_EMA=100*DS_EMAtop/DS_EMAbottom;
SetIndexValue(shift, DS_EMA);
SetIndexValue2(shift, 100*mtmInt/mtmInt1);
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;
DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
// If shift>10 then AccountedBars=AccountedBars+1;
End;

Forex Trader
114255
Forex Trader 2006.07.29 00:36  
Перекючи ME на русский язык, скопируй код и вставь здесь.
Forex Trader
114255
Forex Trader 2006.07.29 01:02  
Перекючи ME на русский язык, скопируй код и вставь здесь.


/*[[
	Name := DS(q,r,s) 
	Author := 
	Link := 
	Separate Window := yes
	First Color := Red
	First Draw Type := Line
	First Symbol := 217
	Use Second Data := Yes
	Second Color := LawnGreen
	Second Draw Type := Line
	Second Symbol := 218
]]*/
Input: qPeriod(13), rPeriod(32), EMAfast(5), CountBars(6000);
Variables : mtm(0),mtmInt(0), mtmIntPrev(0);
Variables : mtm1(0),mtmInt1(0), mtmIntPrev1(0);
Variables : DS_EMA(0),krPeriod(0),kEMAfast(0);
Variables : DS_EMAtopPrev(0), DS_EMAtop(0),DS_EMAbottomPrev(0), DS_EMAbottom(0);
Variables : cnt(0),shift(0),AccountedBars(0),firstTime(True);

If firstTime then
 {
   krPeriod=2/(rPeriod+1);
   kEMAfast=2/(EMAfast+1);
   AccountedBars = Bars-CountBars;
   For  shift = CountBars DownTo 0 Begin
    SetIndexValue(shift, 0);
    SetIndexValue2(shift, 0);
   End;
   firstTime=False;
 };
mtmIntPrev=0; mtmIntPrev1=0; DS_EMAtopPrev=0;DS_EMAbottomPrev=0;
For  cnt = AccountedBars To Bars Begin
 shift = Bars - cnt;
 mtm=Close[shift]-Low[Lowest(MODE_LOW,shift+qPeriod-1,qPeriod)];
 If mtm=0 Then mtm=Point;
 mtm1=High[Highest(MODE_HIGH,shift+qPeriod-1,qPeriod)]-
      Low[Lowest(MODE_LOW,shift+qPeriod-1,qPeriod)];
 If mtm1=0 Then mtm1=Point;
 mtmInt=mtmIntPrev+krPeriod*(mtm-mtmIntPrev); 
 mtmInt1=mtmIntPrev1+krPeriod*(mtm1-mtmIntPrev1); 
 If shift=CountBars Then 
  {
   mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
   Continue; 
  };
 DS_EMAtop=DS_EMAtopPrev+kEMAfast*(mtmInt-DS_EMAtopPrev); 
 DS_EMAbottom=DS_EMAbottomPrev+kEMAfast*(mtmInt1-DS_EMAbottomPrev); 
 If shift=CountBars-1 Then 
  {
   mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
   DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
   Continue; 
  };
 DS_EMA=100*DS_EMAtop/DS_EMAbottom;
 SetIndexValue(shift, DS_EMA);
 SetIndexValue2(shift, 100*mtmInt/mtmInt1);
 mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1; 
 DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
// If shift>10 then AccountedBars=AccountedBars+1;
End;

.

Forex Trader
114255
Forex Trader 2006.08.01 16:34  
Народ, помогите, пожалуйста, исправить ошибки. Для профессионала это ведь пара минут.



//+------------------------------------------------------------------+
//| Stochastic.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#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 LightGreen
#property indicator_color2 Red
//---- input parameters
extern int qPeriod=13;
extern int rPeriod=32;
extern int EMAfast=5;
extern int CountBars=6000;
extern bool firstTime=true;
int cnt, shift;
double mtm[],mtmInt[],mtmIntPrev[],mtm1[],mtmInt1[],mtmIntPrev1[],DS_EMA[],krPeriod[],kEMAfast[],DS_EMAtopPrev[],DS_EMAtop[],DS_EMAbottomPrev[],DS_EMAbottom[];
double AccountedBars[];
//---- buffers
//double MainBuffer[];
//double SignalBuffer[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//double HighesBuffer[];
//double LowesBuffer[];
//----
//int draw_begin1=0;
//int draw_begin2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//----
IndicatorBuffers(2);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexBuffer(1, ExtMapBuffer2);
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
//----
short_name="Sto("ExtMapBuffer1","ExtMapBuffer2")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"Signal");
//----
//draw_begin1=KPeriod+Slowing;
//draw_begin2=draw_begin1+DPeriod;
SetIndexDrawBegin(0,CountBars);
SetIndexDrawBegin(1,CountBars);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Stochastic oscillator |
//+------------------------------------------------------------------+
int start()

if firstTime==true
{
krPeriod=2/(rPeriod+1);
kEMAfast=2/(EMAfast+1);
AccountedBars = Bars-CountBars;
for (shift=CountBars; shift>0; shift--)
ExtMapBuffer1[shift]=0;
ExtMapBuffer2[shift]=0;

firstTime==False;
};
mtmIntPrev=0; mtmIntPrev1=0; DS_EMAtopPrev=0;DS_EMAbottomPrev=0;
for (cnt=AccountedBars; cnt>Bars; cnt--)
shift = Bars - cnt;
mtm=Close[shift]-Low[Lowest(NULL,0,MODE_LOW,shift+qPeriod-1,qPeriod)];
if mtm=0
mtm=Point;
mtm1=High[Highest(NULL,0,MODE_HIGH,shift+qPeriod-1,qPeriod)]-
Low[Lowest(NULL,0,MODE_LOW,shift+qPeriod-1,qPeriod)];
if mtm1=0
mtm1=Point;
mtmInt=mtmIntPrev+krPeriod*(mtm-mtmIntPrev);
mtmInt1=mtmIntPrev1+krPeriod*(mtm1-mtmIntPrev1);
if shift=CountBars
{
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
continue;
};
DS_EMAtop=DS_EMAtopPrev+kEMAfast*(mtmInt-DS_EMAtopPrev);
DS_EMAbottom=DS_EMAbottomPrev+kEMAfast*(mtmInt1-DS_EMAbottomPrev);
if shift=CountBars-1
{
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;;
DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
continue;
};
DS_EMA=100*DS_EMAtop/DS_EMAbottom;
ExtMapBuffer1[shift]=DS_EMA;
ExtMapBuffer2[shift]=100*mtmInt/mtmInt1;
mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;
DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
// If shift>10 then AccountedBars=AccountedBars+1;
//----
return(0);
}
//+------------------------------------------------------------------+
Forex Trader
114255
Forex Trader 2006.08.05 22:51  

//+------------------------------------------------------------------+
//|                                                   Stochastic.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#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 LightGreen
#property indicator_color2 Red
//---- input parameters
extern int qPeriod=13;
extern int rPeriod=32;
extern int EMAfast=5;
extern int CountBars=6000;
extern bool firstTime=true;
int cnt, shift;
double mtm,mtmInt,mtmIntPrev,mtm1,mtmInt1,mtmIntPrev1,DS_EMA,krPeriod,kEMAfast,DS_EMAtopPrev,DS_EMAtop,DS_EMAbottomPrev,DS_EMAbottom;
double AccountedBars;
//---- buffers
//double MainBuffer[];
//double SignalBuffer[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//double HighesBuffer[];
//double LowesBuffer[];
//----
//int draw_begin1=0;
//int draw_begin2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   //string short_name;
//---- 
 //  IndicatorBuffers(2);
//   SetIndexBuffer(0, ExtMapBuffer1);
//   SetIndexBuffer(1, ExtMapBuffer2);
//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1, ExtMapBuffer2);
//---- 
   //short_name="Sto("Main","Signal")";
  // IndicatorShortName(short_name);
  // SetIndexLabel(0,short_name);
  // SetIndexLabel(1,"Signal");
//----
   //draw_begin1=KPeriod+Slowing;
   //draw_begin2=draw_begin1+DPeriod;
   SetIndexDrawBegin(0,CountBars);
   SetIndexDrawBegin(1,CountBars);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Stochastic oscillator                                            |
//+------------------------------------------------------------------+
int start()
   {
  
    if (firstTime==true)
   {
   krPeriod=2/(rPeriod+1);
   kEMAfast=2/(EMAfast+1);
   AccountedBars = Bars-CountBars;
   for (shift=CountBars; shift>0; shift--)
    ExtMapBuffer1[shift]=0;
    ExtMapBuffer2[shift]=0;
    return(0);
    }
    
  if (firstTime==false)
 

mtmIntPrev=0; mtmIntPrev1=0; DS_EMAtopPrev=0;DS_EMAbottomPrev=0;
for  (cnt=AccountedBars; cnt>Bars; cnt--)
 shift = Bars - cnt;
 mtm=Close[shift]-Low[Lowest(NULL,0,MODE_LOW,shift+qPeriod-1,qPeriod)];
  
 if (mtm==0)  
 
 mtm=Point;
 mtm1=High[Highest(NULL,0,MODE_HIGH,shift+qPeriod-1,qPeriod)]-
      Low[Lowest(NULL,0,MODE_LOW,shift+qPeriod-1,qPeriod)];
      
 if (mtm1==0)
 mtm1=Point;
 mtmInt=mtmIntPrev+krPeriod*(mtm-mtmIntPrev); 
 mtmInt1=mtmIntPrev1+krPeriod*(mtm1-mtmIntPrev1); 
 
 if (shift==CountBars) 
  {
   mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;
   //continue; 
  }
 DS_EMAtop=DS_EMAtopPrev+kEMAfast*(mtmInt-DS_EMAtopPrev); 
 DS_EMAbottom=DS_EMAbottomPrev+kEMAfast*(mtmInt1-DS_EMAbottomPrev); 
 
 if (shift==CountBars-1) 
  {
   mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1;
   DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;
   //continue; 
  }
 DS_EMA=100*DS_EMAtop/DS_EMAbottom;
 ExtMapBuffer1[shift-1]=100*mtmInt/mtmInt1;
 ExtMapBuffer2[shift]=100*mtmInt/mtmInt1;
 mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1; 
 DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;

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

.

Помогите понять в чем ошибка? Почему не прорисовываются линии?

Forex Trader
114255
Forex Trader 2006.08.07 00:32  
подправил.

//+------------------------------------------------------------------+
//|                                                           DS.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#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 Red
#property indicator_color2 LightGreen
//---- input parameters
extern int qPeriod=13;
extern int rPeriod=32;
extern int EMAfast=5;
extern int CountBars=300;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
double krPeriod,kEMAfast;
double mtm,mtmInt,mtmIntPrev,mtm1,mtmInt1,mtmIntPrev1,DS_EMA;
double DS_EMAtopPrev,DS_EMAtop,DS_EMAbottomPrev,DS_EMAbottom,DS;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1, ExtMapBuffer2);
//---- 
   krPeriod=2/(rPeriod+1.0);
   kEMAfast=2/(EMAfast+1.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DS                                                               |
//+------------------------------------------------------------------+
int start()
   {
   
int shift;
mtmIntPrev=0.0; mtmIntPrev1=0.0; DS_EMAtopPrev=0.0; DS_EMAbottomPrev=0.0;
for  (shift=CountBars; shift>=0; shift--)
{

 mtm=Close[shift]-Low[Lowest(NULL,0,MODE_LOW,qPeriod,shift)];
  
 if (mtm==0) mtm=Point;
 
 mtm1=High[Highest(NULL,0,MODE_HIGH,qPeriod,shift)]-Low[Lowest(NULL,0,MODE_LOW,qPeriod,shift)];
      
 if (mtm1==0) mtm1=Point;
 
 mtmInt=mtmIntPrev+krPeriod*(mtm-mtmIntPrev); 
 mtmInt1=mtmIntPrev1+krPeriod*(mtm1-mtmIntPrev1); 

 DS_EMAtop=DS_EMAtopPrev+kEMAfast*(mtmInt-DS_EMAtopPrev); 
 DS_EMAbottom=DS_EMAbottomPrev+kEMAfast*(mtmInt1-DS_EMAbottomPrev); 
 
 DS=100*mtmInt/mtmInt1;
 DS_EMA=100*DS_EMAtop/DS_EMAbottom;
 
 ExtMapBuffer1[shift]=DS;
 ExtMapBuffer2[shift]=DS_EMA;
 
 mtmIntPrev=mtmInt; mtmIntPrev1=mtmInt1; 
 DS_EMAtopPrev=DS_EMAtop; DS_EMAbottomPrev=DS_EMAbottom;

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



Forex Trader
114255
Forex Trader 2006.08.08 00:40  
Ramdass, огромное спасибо!
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий