Переписать индикатор с руланга на mg5

MQL5 Indicateurs

Tâche terminée

Temps d'exécution 3 heures
Commentaires du client
Работу выполнил от... и до...
Commentaires de l'employé
Однозначное ТЗ и никаких задержек с проверкой результата - всё отлично.

Spécifications

Переписать индикатор с Руланг(Румус) Форекс Клуба на mg5

Есть код на Руланг , и на mg4. Базовая версия, с которой будем сравнивать естественно код Румуса.

//!_IC_2
sp=inparam("PERIOD",1,1000,20);
if c>o then xh=h-c;else xh=h-o;
if c>o then xl=o-l;else xl=c-l;
tsh=mov(xh,sp,s);
tsl=mov(xl,sp,s);
//покупка
if xl>2*tsl or (c-o)> 2*tsh
   or (xl>2*xh and xl>tsl) then br=3; else br=0;
if (o-c)>2*tsl then br=0;
//r;
//продажа
if xh>2*tsh or (o-c)> 2*tsl
   or (xh>2*xl and xh>tsh) then sr=-3; else sr=0;
if abs(xh-xl)<((tsh+tsl)/2)
   and abs (o-c)<((tsh+tsl)/2) then
begin br=0;
sr=0;
end;
if (c-o)>2*tsh then sr=0;
//дожи
d=(tsh-tsl);
d1=abs(xh-xl);
d2=abs(o-c);
if d2<=d and d1<=d then 
begin sr=0; br=0; end;
a=h;
b=ref(h,-1);
if a>b then h2=a; else h2=b;
a1=l;
b1=ref(l,-1);
if a1<b1 then l2=a1; else l2=b1;
o2=ref(o,-1);
c2=c;
//покупка
if c2>h2-(h2-l2)/3 then br2=1; else br2=0;
//r2;
//продажа
if c2<l2+(h2-l2)/3 then sr2=-1; else sr2=0;
zzz=sr2+br2+br+sr;
if zzz>0 then rr=zzz; else rr=0;
if zzz<0 then rr1=zzz; else rr1=0;
rr;
rr1;

Вот код для МТ4

 //+------------------------------------------------------------------+

//|                                                       !_IC_2.mq4 |
//|                                                   Nikolay Kobzar |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Nikolay Kobzar"
#property link      "www.traderacademy.ru"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

double rr[];
double rr1[];
double xh[];
double xl[];

extern int sp = 20;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorShortName("!_IC_2");
   IndicatorBuffers(4);
   SetIndexBuffer(0,rr);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexLabel(0,"rr");
   SetIndexBuffer(1,rr1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexLabel(1,"rr1");   
   
   SetIndexBuffer(2,xh);
   SetIndexBuffer(3,xl);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();

   if (Bars <= sp) return(0);
   if (counted_bars < 0) return(-1);
   if (counted_bars > 0) counted_bars--;

   int loopbegin = Bars - counted_bars - 1;
   
   double tsh, tsl;    
   int i,j;
   int br,sr,br2,sr2,zzz;
   double d,d1,d2,a,b,h2,a1,b1,l2,c2,o2;
   
   for(i=loopbegin; i>=0; i--) {
     if (Close[i] > Open[i]) {
       xh[i] = High[i]-Close[i];
       xl[i] = Open[i]-Low[i]; }
     else {
       xh[i] = High[i]-Open[i];
       xl[i] = Close[i]-Low[i];}         
   }
       
   for(i=loopbegin; i>=0; i--) {
     tsh=0;
     tsl=0;
     for (j=0;j<sp;j++) {
       tsh = tsh + xh[i+j];
       tsl = tsl + xl[i+j];
     }   
     tsh = tsh / sp;
     tsl = tsl / sp;   
     
     if ( (xl[i]>2*tsl) || (Close[i]-Open[i]>2*tsh)
          || ((xl[i]>2*xh[i]) && (xl[i]>tsl)) ) br=3; else br=0;
     if ( (Open[i]-Close[i])>2*tsl ) br=0;
     
     if ( (xh[i]>2*tsl) || (Open[i]-Close[i]>2*tsl) 
          || (xh[i]>2*xl[i] && xh[i]>tsh) ) sr=-3; else sr=0;
     if ( (MathAbs(xh[i]-xl[i]) < ((tsh+tsl)/2)) 
          && (MathAbs(Open[i]-Close[i])<((tsh+tsl)/2)) ) { br=0; sr=0;}
     if ( (Close[i]-Open[i])>2*tsh ) sr=0;
     
     d = tsh-tsl;
     d1 = MathAbs(xh[i]-xl[i]);
     d2 = MathAbs(Open[i]-Close[i]);
     if ( (d2<=d) && (d1<=d) ) { sr=0; br=0; }
     
     a=High[i];
     b=High[i+1];
     if (a>b) h2=a; else h2=b;
     a1=Low[i];
     b1=Low[i+1];
     if (a1<b1) l2=a1; else l2=b1;
     o2=Open[i+1];
     c2=Close[i];
     
     if (c2 > h2-(h2-l2)/3) br2=1; else br2=0;
     
     if (c2 < l2+(h2-l2)/3) sr2=-1; else sr2=0;
     zzz=sr2+br2+br+sr;
     if (zzz>0) rr[i]=zzz; else rr[i]=0;
     if (zzz<0) rr1[i]=zzz; else rr1[i]=0; 
   }
//----

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

Répondu

1
Développeur 1
Évaluation
(3)
Projets
4
25%
Arbitrage
0
En retard
0
Gratuit
2
Développeur 2
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
3
Développeur 3
Évaluation
(812)
Projets
1389
72%
Arbitrage
114
29% / 47%
En retard
344
25%
Travail

Informations sur le projet

Budget