Помогите поправить индикатор.

 

Здравствуйте уважаемые программисты!

Помогите поправить данный индикатор T3_DPO-v2 имеются 12 ошибок при которых не возможно сделать комплект через Мт4.

Буду очень Вам благодарен за вашу помощь новичку.

Ошибки:

'T3_DPO-v2.mq4' T3_DPO-v2.mq4   1       1
'char' - unexpected token       T3_DPO-v2.mq4   481     11
'=' - name expected     T3_DPO-v2.mq4   481     16
')' - semicolon expected        T3_DPO-v2.mq4   481     41
'>' - unexpected token  T3_DPO-v2.mq4   482     19
'<' - unexpected token  T3_DPO-v2.mq4   482     32
'||' - operand expected T3_DPO-v2.mq4   482     39
'>' - unexpected token  T3_DPO-v2.mq4   482     48
'<' - unexpected token  T3_DPO-v2.mq4   482     62
')' - unexpected token  T3_DPO-v2.mq4   482     67
expression has no effect        T3_DPO-v2.mq4   482     54
')' - unexpected token  T3_DPO-v2.mq4   482     68
'-' - unexpected token  T3_DPO-v2.mq4   483     56
'else' - illegal 'else' without matching 'if'   T3_DPO-v2.mq4   484     10
12 error(s), 1 warning(s)               13      2

Код индикатора:

//+------------------------------------------------------------------+
//|                                                    T3 DPO v2.mq4 |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 DeepSkyBlue
#property indicator_color5 Red
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2

//
//
//
//
//

extern string TimeFrame   = "Current time frame";
extern int    T3Period    = 8;
extern double T3Hot       = 0.7;
extern bool   T3Original  = false;
extern int    UsePrice    = PRICE_CLOSE;
extern bool   Interpolate = true;

//
//
//
//
//

extern string _                     = "arrows settings";
extern bool   showArrowsOnChart     = true;
extern bool   showArrowsOnIndicator = true;
extern string arrowsIdentifier      = "T3_dpo_arrows";
extern color  arrowsUpColor         = DeepSkyBlue;
extern color  arrowsDnColor         = Red;

extern string __                    = "alerts settings";
extern bool   alertsOn              = true;
extern bool   alertsOnCurrent       = true;
extern bool   alertsMessage         = true;
extern bool   alertsSound           = false;
extern bool   alertsEmail           = false;

//
//
//
//
//

double t3[];
double t3d[];
double priceLine[];
double arrowUp[];
double arrowDn[];
double trend[];
double slopeTrend[];

//
//
//
//
//

int    timeFrame;
string IndicatorFileName;
bool   ReturningBars;
bool   CalculatingDpo;

double alpha;
double c1;
double c2;
double c3;
double c4;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(7);
   SetIndexBuffer(0,t3);  SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,t3d); SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(2,priceLine);
   SetIndexBuffer(3,arrowUp);
   SetIndexBuffer(4,arrowDn);
   SetIndexBuffer(5,trend);
   SetIndexBuffer(6,slopeTrend);
      if (showArrowsOnIndicator)
      {
         SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,159);
         SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,159);
      }
      else
      {
         SetIndexStyle(3,DRAW_NONE);
         SetIndexStyle(4,DRAW_NONE);
      }

   //
   //
   //
   //
   //
   
      double a  = T3Hot;
             c1 = -a*a*a;
             c2 =  3*(a*a+a*a*a);
             c3 = -3*(2*a*a+a+a*a*a);
             c4 = 1+3*a+a*a*a+3*a*a;

      T3Period = MathMax(1,T3Period);
      if (T3Original)
           alpha = 2.0/(1.0 + T3Period);
      else alpha = 2.0/(2.0 + (T3Period-1.0)/2.0);

      //
      //
      //
      //
      //
         
      IndicatorFileName = WindowExpertName();
      CalculatingDpo    = (TimeFrame=="CalculateDpo"); if (CalculatingDpo) return(0);
      ReturningBars     = (TimeFrame=="returnBars");   if (ReturningBars)  return(0);
      timeFrame         = stringToTimeFrame(TimeFrame);
      
   //
   //
   //
   //
   //
         
   IndicatorShortName("T3 dpo "+timeFrameToString(timeFrame)+" ("+T3Period+","+DoubleToStr(T3Hot,2)+")");
   return(0);
}
int deinit()
{
   if (showArrowsOnChart) deleteArrows();
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = MathMin(Bars-counted_bars,Bars-1);
         if (ReturningBars) { t3[0] = limit+1; return(0); }

   //
   //
   //
   //
   //

   if (CalculatingDpo || timeFrame==Period())
   {
      for(i=limit; i>=0; i--)
      {
         priceLine[i]  =     iMA(NULL,0,1       ,0,MODE_SMA,UsePrice,i);
         t3[i]         = iT3(iMA(NULL,0,T3Period,0,MODE_SMA,UsePrice,i),i,0);
         
         //
         //
         //
         //
         //
         
         if (!CalculatingDpo)
         {
            manageArrows(i);
               t3d[i]        = EMPTY_VALUE;
               slopeTrend[i] = slopeTrend[i+1];
                  if (t3[i]>t3[i+1]) slopeTrend[i] =  1;
                  if (t3[i]<t3[i+1]) slopeTrend[i] = -1;
                  if (slopeTrend[i] == -1) t3d[i] = t3[i];
         }                  
      }
      if (!CalculatingDpo) manageAlerts();
      return(0);
   }
   
   //
   //
   //
   //
   //
         
   if (timeFrame > Period()) limit = MathMax(limit,MathMin(Bars,iCustom(NULL,timeFrame,IndicatorFileName,"returnBars",0,0)*timeFrame/Period()));
   for (i=limit;i>=0;i--)
   {
      int y = iBarShift(NULL,timeFrame,Time[i]);
         priceLine[i]  = iMA(NULL,timeFrame,1,0,MODE_SMA,UsePrice,y);
         t3[i]         = iCustom(NULL,timeFrame,IndicatorFileName,"CalculateDpo",T3Period,T3Hot,T3Original,UsePrice,0,y);
         t3d[i]        = EMPTY_VALUE;
         slopeTrend[i] = slopeTrend[i+1];
                  if (t3[i]>t3[i+1]) slopeTrend[i] =  1;
                  if (t3[i]<t3[i+1]) slopeTrend[i] = -1;
                  if (slopeTrend[i] == -1) t3d[i] = t3[i];
            manageArrows(i);

         //
         //
         //
         //
         //
      
         if (timeFrame <= Period() || y==iBarShift(NULL,timeFrame,Time[i-1])) continue;
         if (!Interpolate) continue;

         //
         //
         //
         //
         //

         datetime time = iTime(NULL,timeFrame,y);
            for(int n = 1; i+n < Bars && Time[i+n] >= time; n++) continue;      
            double factor = 1.0 / n;
            for(int k = 1; k < n; k++)
            {
               priceLine[i+k] = k*factor*priceLine[i+n] + (1.0-k*factor)*priceLine[i];
               t3[i+k]        = k*factor*t3[i+n]        + (1.0-k*factor)*t3[i];
               
               //
               //
               //
               //
               //
               
               if (slopeTrend[i]==-1) t3d[i+k] = t3[i+k];
            }               
   }
   manageAlerts();
      
   //
   //
   //
   //
   //
   
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

double _t3Values[][6];
double iT3(double price,int i,int s)
{
   if (ArrayRange(_t3Values,0) != Bars) ArrayResize(_t3Values,Bars);

   int r = Bars-i-1;
   if (r < 2)
      {
         _t3Values[r][s+0] = price;
         _t3Values[r][s+1] = price;
         _t3Values[r][s+2] = price;
         _t3Values[r][s+3] = price;
         _t3Values[r][s+4] = price;
         _t3Values[r][s+5] = price;
      }
   else
      {
         _t3Values[r][s+0] = _t3Values[r-1][s+0]+alpha*(price            -_t3Values[r-1][s+0]);
         _t3Values[r][s+1] = _t3Values[r-1][s+1]+alpha*(_t3Values[r][s+0]-_t3Values[r-1][s+1]);
         _t3Values[r][s+2] = _t3Values[r-1][s+2]+alpha*(_t3Values[r][s+1]-_t3Values[r-1][s+2]);
         _t3Values[r][s+3] = _t3Values[r-1][s+3]+alpha*(_t3Values[r][s+2]-_t3Values[r-1][s+3]);
         _t3Values[r][s+4] = _t3Values[r-1][s+4]+alpha*(_t3Values[r][s+3]-_t3Values[r-1][s+4]);
         _t3Values[r][s+5] = _t3Values[r-1][s+5]+alpha*(_t3Values[r][s+4]-_t3Values[r-1][s+5]);
      }
   return(c1*_t3Values[r][s+5] + c2*_t3Values[r][s+4] + c3*_t3Values[r][s+3] + c4*_t3Values[r][s+2]);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//
   
void manageAlerts()
{
   if (alertsOn)
   {
      if (alertsOnCurrent)
           int whichBar = 0;
      else     whichBar = 1; whichBar = iBarShift(NULL,0,iTime(NULL,timeFrame,whichBar));
      if (trend[whichBar] != trend[whichBar+1])
      {
         if (trend[whichBar] == 1) doAlert(whichBar,"up");
         if (trend[whichBar] ==-1) doAlert(whichBar,"down");
      }         
   }
}

//
//
//
//
//

void doAlert(int forBar, string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
   if (previousAlert != doWhat || previousTime != Time[forBar]) {
       previousAlert  = doWhat;
       previousTime   = Time[forBar];

       //
       //
       //
       //
       //

       message =  StringConcatenate(Symbol(),timeFrameToString(timeFrame)+" at ",TimeToStr(TimeLocal(),TIME_SECONDS)," T3 DPO trend changed to ",doWhat);
          if (alertsMessage) Alert(message);
          if (alertsEmail)   SendMail(StringConcatenate(Symbol(),"T3 DPO trend "),message);
          if (alertsSound)   PlaySound("alert2.wav");
   }
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void manageArrows(int i)
{
   trend[i] = trend[i+1];
      if (priceLine[i]>t3[i]) trend[i] =  1;
      if (priceLine[i]<t3[i]) trend[i] = -1;
      if (showArrowsOnChart)
      {
         deleteArrow(Time[i]);
         if (trend[i]!=trend[i+1])
         {
            if (trend[i] == 1) drawArrow(i,arrowsUpColor,241,false);
            if (trend[i] ==-1) drawArrow(i,arrowsDnColor,242,true);
          }
      }
      if (showArrowsOnIndicator)
      {
         arrowUp[i] = EMPTY_VALUE;
         arrowDn[i] = EMPTY_VALUE;
         if (trend[i]!=trend[i+1])
         {
            if (trend[i] == 1) arrowUp[i] = t3[i];
            if (trend[i] ==-1) arrowDn[i] = t3[i];
         }
      }
}               

//
//
//
//
//

void drawArrow(int i,color theColor,int theCode,bool up)
{
   string name = arrowsIdentifier+":"+Time[i];
   double gap  = 3.0*iATR(NULL,0,20,i)/4.0;   
   
      //
      //
      //
      //
      //
      
      ObjectCreate(name,OBJ_ARROW,0,Time[i],0);
         ObjectSet(name,OBJPROP_ARROWCODE,theCode);
         ObjectSet(name,OBJPROP_COLOR,theColor);
         if (up)
               ObjectSet(name,OBJPROP_PRICE1,High[i]+gap);
         else  ObjectSet(name,OBJPROP_PRICE1,Low[i] -gap);
}

//
//
//
//
//

void deleteArrows()
{
   string lookFor       = arrowsIdentifier+":";
   int    lookForLength = StringLen(lookFor);
   for (int i=ObjectsTotal()-1; i>=0; i--)
   {
      string objectName = ObjectName(i);
         if (StringSubstr(objectName,0,lookForLength) == lookFor) ObjectDelete(objectName);
   }
}
void deleteArrow(datetime time)
{
   string lookFor = arrowsIdentifier+":"+time; ObjectDelete(lookFor);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
   tfs = StringUpperCase(tfs);
   for (int i=ArraySize(iTfTable)-1; i>=0; i--)
         if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period()));
                                                      return(Period());
}
string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

//
//
//
//
//

string StringUpperCase(string str)
{
   string   s = str;

   for (int length=StringLen(str)-1; length>=0; length--)
   {
      int char = StringGetChar(s, length);
         if((char > 96 && char < 123) || (char > 223 && char < 256))
                     s = StringSetChar(s, length, char - 32);
         else if(char > -33 && char < 0)
                     s = StringSetChar(s, length, char + 224);
   }
   return(s);
}
 
Atrin:

Здравствуйте уважаемые программисты!

Помогите поправить данный индикатор T3_DPO-v2 имеются 12 ошибок при которых не возможно сделать комплект через Мт4.

Буду очень Вам благодарен за вашу помощь новичку.

Ошибки:

Код индикатора:


Пробуй

Файлы:
T3_DPO-v2.mq4  13 kb
2y1vcf.PNG  50 kb
 
Eduard Bartashevich:

Пробуй


Спасибо за помощь! Работает в Мт4.

 

Eduard Bartashevich, а возможно еще его поправить чтобы он в Бек-тестере работал? Если это вас не затруднит.

 

Добрый день, на примере Вашего индикатора, подскажите, пожалуйста, для новчика, в каком момент в указанной ниже строке переменная TimeFrame становится равной "CalculateDpo". Не понимаю смысла указанной ниже строчки:

 CalculatingDpo    = (TimeFrame=="CalculateDpo"); if (CalculatingDpo) return(0);

Правильно ли я понимаю, что это происходит в момент вызова iCustom в строке ниже?

t3[i]         = iCustom(NULL,timeFrame,IndicatorFileName,"CalculateDpo",T3Period,T3Hot,T3Original,UsePrice,0,y);

Не могу понять, почему в iCustom вместо таймфрейма в параметр TimeFrame передаётся "CalculateDpo", какой смысл в этом...

 
Я не автор индикатора вашего, но судя по всему 
"CalculateDpo"

это строковая переменная или(и) имя файла.

 
Volodymyr Zubov #:
Я не автор индикатора вашего, но судя по всему 

это строковая переменная или(и) имя файла.

Спасибо!
Причина обращения: