Page 15 of 66

Re: Does this indicator repaint?

Posted: Sun Oct 22, 2017 5:00 pm
by Rockweli
Hi mr mntiwana,
please tell me is this "trend lord " indicator repanting ?


https://www.forex-station.com/viewtopic ... 1295352309


Re: Does this indicator repaint?

Posted: Sun Oct 22, 2017 5:44 pm
by mntiwana
Rockweli wrote: Sun Oct 22, 2017 5:00 pm Hi mr mntiwana,
please tell me is this "trend lord " indicator repanting ?


https://www.forex-station.com/viewtopic ... 1295352309


Trend Lord.mq4
Sorry dont know as i have not tested,may be experts can better explain by seeing inside code

Re: Does this indicator repaint?

Posted: Fri Nov 03, 2017 11:50 pm
by ekmanso1
Hello I would like to know if Dt ZIGZAG LAUER repaints or recalculates in any way... please bear with my naive and newbish question.

Re: Does this indicator repaint?

Posted: Sat Nov 04, 2017 12:57 am
by Krelian99
ekmanso1 wrote: Fri Nov 03, 2017 11:50 pm Hello I would like to know if Dt ZIGZAG LAUER repaints or recalculates in any way... please bear with my naive and newbish question.
Zigzigs always repaint.

Re: Does this indicator repaint?

Posted: Thu Nov 16, 2017 10:55 am
by yuhu
Hi all, would you please kindly let me know if the attached is repainting? it seems quite straightforward to be needing to repaint

Many thanks in advance

Code: Select all

//+------------------------------------------------------------------+
//|                                                       Extent.mq4 |
//|                               Copyright © 2017, Gehtsoft USA LLC |
//|                                            http://fxcodebase.com |
//+------------------------------------------------------------------+
//|                         Donate / Support:  https://goo.gl/9Rj74e |
//|                     BitCoin: 15VCJTLaz12Amr7adHSBtL9v8XomURo9RF  | 
//+------------------------------------------------------------------+
//|                                      Developed by : Mario Jemic  |                    
//|                                          mario.jemic@gmail.com   |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2017, Gehtsoft USA LLC"
#property link      "http://fxcodebase.com"

#property description "This indicator shows the difference between a MA and Price"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 clrLime
#property indicator_width1 3
#property indicator_color2 clrRed
#property indicator_width2 3
#property indicator_color3 clrLime
#property indicator_width3 3
#property indicator_color4 clrRed
#property indicator_width4 3
#property indicator_levelcolor clrYellow
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_DOT

enum e_method{ SMA        =  1,
               EMA        =  2,
               Wilder     =  3,
               LWMA       =  4,
               SineWMA    =  5,
               TriMA      =  6,
               LSMA       =  7,
               SMMA       =  8,
               HMA        =  9,
               ZeroLagEMA = 10,
               ITrend     = 11,
               Median     = 12,
               GeoMean    = 13,
               REMA       = 14,
               ILRS       = 15,
               IE_2       = 16,
               TriMAgen   = 17
             };

enum e_price{ CLOSE=PRICE_CLOSE, OPEN=PRICE_OPEN, LOW=PRICE_LOW, HIGH=PRICE_HIGH, MEDIAN=PRICE_MEDIAN, TYPICAL=PRICE_TYPICAL, WEIGHTED=PRICE_WEIGHTED };

extern e_method MA_Method = SMA;
extern int      MA_Period = 36;
extern e_price  MA_Price  = CLOSE;

double Extent_Up_Plus[];
double Extent_Up_Minus[];
double Extent_Dn_Plus[];
double Extent_Dn_Minus[];
double Extent[];
double MA[];
double Price[];

int init(){
   
   IndicatorShortName("Extent");
   IndicatorBuffers(7);
   
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,Extent_Up_Plus);
   SetIndexLabel(0,"Extent Up");
   SetIndexDrawBegin(0,MA_Period);
   
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,Extent_Up_Minus);
   SetIndexLabel(1,"Extent Up");
   SetIndexDrawBegin(1,MA_Period);
   
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,Extent_Dn_Plus);
   SetIndexLabel(2,"Extent Dn");
   SetIndexDrawBegin(2,MA_Period);
   
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,Extent_Dn_Minus);
   SetIndexLabel(3,"Extent Dn");
   SetIndexDrawBegin(3,MA_Period);
   
   SetIndexBuffer(4,Extent);
   SetIndexBuffer(5,MA);
   SetIndexBuffer(6,Price);
   
   SetLevelValue(0,0);
   
   return(0);
}

int start()
  {
   
   int i;
   int counted_bars=IndicatorCounted();
   int limit = Bars-counted_bars-1;
   
   for (i=limit; i>=0; i--){
      
      Price[i] = iMA(NULL,0,1,0,0,ENUM_APPLIED_PRICE(MA_Price),i);
      
   }
   
   for (i=limit; i>=0; i--){
      
      switch(MA_Method){
         case 1 :
            MA[i] = SMA(Price,MA_Period,i);
            break;
         case 2 :
            MA[i] = EMA(Price[i],MA[i+1],MA_Period,i);
            break;
         case 3 :
            MA[i] = Wilder(Price[i],MA[i+1],MA_Period,i);
            break;  
         case 4 :
            MA[i] = LWMA(Price,MA_Period,i);
            break;
         case 5 :
            MA[i] = SineWMA(Price,MA_Period,i);
            break;
         case 6 :
            MA[i] = TriMA(Price,MA_Period,i);
            break;
         case 7 :
            MA[i] = LSMA(Price,MA_Period,i);
            break;
         case 8 :
            MA[i] = SMMA(Price,MA[i+1],MA_Period,i);
            break;
         case 9 :
            MA[i] = HMA(Price,MA_Period,i);
            break;
         case 10:
            MA[i] = ZeroLagEMA(Price,MA[i+1],MA_Period,i);
            break;
         case 11:
            MA[i] = ITrend(Price,MA,MA_Period,i);
            break;
         case 12:
            MA[i] = Median(Price,MA_Period,i);
            break;
         case 13:
            MA[i] = GeoMean(Price,MA_Period,i);
            break;
         case 14:
            MA[i] = REMA(Price[i],MA,MA_Period,0.5,i);
            break;
         case 15:
            MA[i] = ILRS(Price,MA_Period,i);
            break;
         case 16:
            MA[i] = IE2(Price,MA_Period,i);
            break;
         case 17:
            MA[i] = TriMA_gen(Price,MA_Period,i);
            break;
         default:
            MA[i] = SMA(Price,MA_Period,i);
            break;
      }
      
      Extent[i] = Open[i] - MA[i];
      
      if (Extent[i] <= 0){
      
         if (Extent[i] > Extent[i+1])
         
            Extent_Up_Plus[i] = Extent[i];
            
         else
         
            Extent_Up_Minus[i] = Extent[i];
      
      }
      else{
      
         if (Extent[i] > Extent[i+1])
         
            Extent_Dn_Plus[i] = Extent[i];
            
         else
         
            Extent_Dn_Minus[i] = Extent[i];
      
      }
      
   }
   
//----
   return(0);
}
  
double SMA(double &array[],int per,int bar){
   double Sum = 0;
   for(int i = 0;i < per;i++) Sum += array[bar+i];
   return(Sum/per);
}                

double EMA(double price,double prev,int per,int bar){
   if(bar >= Bars - 2)
      double ema = price;
   else 
      ema = prev + 2.0/(1+per)*(price - prev); 
   return(ema);
}

double Wilder(double price,double prev,int per,int bar){
   if(bar >= Bars - 2)
      double wilder = price;
   else 
      wilder = prev + (price - prev)/per; 
   return(wilder);
}

double LWMA(double &array[],int per,int bar){
   double Sum = 0;
   double Weight = 0;
   for(int i = 0;i < per;i++){ 
      Weight+= (per - i);
      Sum += array[bar+i]*(per - i);
   }
   if(Weight>0)
      double lwma = Sum/Weight;
   else
      lwma = 0; 
   return(lwma);
} 

double SineWMA(double &array[],int per,int bar){
   double pi = 3.1415926535;
   double Sum = 0;
   double Weight = 0;
   for(int i = 0;i < per;i++){ 
      Weight+= MathSin(pi*(i+1)/(per+1));
      Sum += array[bar+i]*MathSin(pi*(i+1)/(per+1)); 
   }
   if(Weight>0)
      double swma = Sum/Weight;
   else
      swma = 0; 
   return(swma);
}

double TriMA(double &array[],int per,int bar){
   double sma;
   int len = MathCeil((per+1)*0.5);
   double sum=0;
   for(int i = 0;i < len;i++) {
      sma = SMA(array,len,bar+i);
      sum += sma;
   } 
   double trima = sum/len;
   return(trima);
}

double LSMA(double &array[],int per,int bar){   
   double Sum=0;
   for(int i=per; i>=1; i--) Sum += (i-(per+1)/3.0)*array[bar+per-i];
   double lsma = Sum*6/(per*(per+1));
   return(lsma);
}

double SMMA(double &array[],double prev,int per,int bar){
   if(bar == Bars - per)
      double smma = SMA(array,per,bar);
   else if(bar < Bars - per){
      double Sum = 0;
      for(int i = 0;i < per;i++) Sum += array[bar+i+1];
      smma = (Sum - prev + array[bar])/per;
   }
   return(smma);
}                

double HMA(double &array[],int per,int bar){
   double tmp1[];
   int len = MathSqrt(per);
   ArrayResize(tmp1,len);
   if(bar == Bars - per)
      double hma = array[bar]; 
   else if(bar < Bars - per){
      for(int i=0;i<len;i++) tmp1[i] = 2*LWMA(array,per/2,bar+i) - LWMA(array,per,bar+i);  
      hma = LWMA(tmp1,len,0); 
   }  
   return(hma);
}

double ZeroLagEMA(double &price[],double prev,int per,int bar){
   double alfa = 2.0/(1+per); 
   int lag = 0.5*(per - 1); 
   if(bar >= Bars - lag)
      double zema = price[bar];
   else 
      zema = alfa*(2*price[bar] - price[bar+lag]) + (1-alfa)*prev;
   return(zema);
}

double ITrend(double &price[],double &array[],int per,int bar){
   double alfa = 2.0/(per+1);
   if (bar < Bars - 7)
      double it = (alfa - 0.25*alfa*alfa)*price[bar] + 0.5*alfa*alfa*price[bar+1] - (alfa - 0.75*alfa*alfa)*price[bar+2] + 2*(1-alfa)*array[bar+1] - (1-alfa)*(1-alfa)*array[bar+2];
   else
      it = (price[bar] + 2*price[bar+1] + price[bar+2])/4;
   return(it);
}

double Median(double &price[],int per,int bar){
   double array[];
   ArrayResize(array,per);
   for(int i = 0; i < per;i++) array[i] = price[bar+i];
   ArraySort(array);
   int num = MathRound((per-1)/2); 
   if(MathMod(per,2) > 0) double median = array[num]; else median = 0.5*(array[num]+array[num+1]);
   return(median); 
}

double GeoMean(double &price[],int per,int bar){
   if(bar < Bars - per){ 
      double gmean = MathPow(price[bar],1.0/per); 
      for(int i = 1; i < per;i++) gmean *= MathPow(price[bar+i],1.0/per); 
   }   
   return(gmean);
}

double REMA(double price,double &array[],int per,double lambda,int bar){
   double alpha =  2.0/(per + 1);
   if(bar >= Bars - 3)
      double rema = price;
   else 
      rema = (array[bar+1]*(1+2*lambda) + alpha*(price - array[bar+1]) - lambda*array[bar+2])/(1+lambda);    
   return(rema);
}

double ILRS(double &price[],int per,int bar){
   double sum = per*(per-1)*0.5;
   double sum2 = (per-1)*per*(2*per-1)/6.0;
   double sum1 = 0;
   double sumy = 0;
   for(int i=0;i<per;i++){ 
      sum1 += i*price[bar+i];
      sumy += price[bar+i];
   }
   double num1 = per*sum1 - sum*sumy;
   double num2 = sum*sum - per*sum2;
   if(num2 != 0) double slope = num1/num2; else slope = 0; 
   double ilrs = slope + SMA(price,per,bar);
   return(ilrs);
}

double IE2(double &price[],int per,int bar){
   double ie = 0.5*(ILRS(price,per,bar) + LSMA(price,per,bar));
   return(ie); 
}
 

double TriMA_gen(double &array[],int per,int bar){
   int len1 = MathFloor((per+1)*0.5);
   int len2 = MathCeil((per+1)*0.5);
   double sum=0;
   for(int i = 0;i < len2;i++) sum += SMA(array,len1,bar+i);
   double trimagen = sum/len2;
   return(trimagen);
}

double VWMA(double &array[],int per,int bar){
   double Sum = 0;
   double Weight = 0;
   for(int i = 0;i < per;i++){ 
      Weight+= Volume[bar+i];
      Sum += array[bar+i]*Volume[bar+i];
   }
   if(Weight>0)
      double vwma = Sum/Weight;
   else
      vwma = 0; 
   return(vwma);
} 

Re: Does this indicator repaint?

Posted: Sat Dec 16, 2017 4:24 pm
by heispark
Hello,
Could you please have a look if attached indicators repaint?
Thanks,

Re: Does this indicator repaint?

Posted: Sat Dec 16, 2017 5:21 pm
by mladen
heispark wrote: Sat Dec 16, 2017 4:24 pm Hello,
Could you please have a look if attached indicators repaint?
Thanks,
DDS.mq4Drake Delay Stochastic.mq4
It does
That is a wrongly coded kind of double smoothed stochastic. Here is a version that does not repaint

Re: Does this indicator repaint?

Posted: Sat Dec 16, 2017 7:37 pm
by heispark
mladen wrote: Sat Dec 16, 2017 5:21 pm

It does
That is a wrongly coded kind of double smoothed stochastic. Here is a version that does not repaint

example.png
Thank you so much again, sir! I really appreciate it. :D

Re: Does this indicator repaint?

Posted: Thu Jan 04, 2018 12:59 am
by Naughty 77
Hi All

Would you kindly confirm if the attached indicator repaints ? Ifso, can it be corrected ?

Regards

Naughty 77

Re: Does this indicator repaint?

Posted: Thu Jan 04, 2018 2:11 am
by mrtools
Naughty 77 wrote: Thu Jan 04, 2018 12:59 am Hi All

Would you kindly confirm if the attached indicator repaints ? Ifso, can it be corrected ?

Regards

Naughty 77
It repaints. After correcting it it will not be the same.