Page 8 of 66

Re: Does this indicator repaint?

Posted: Sun May 21, 2017 12:49 am
by mladen
AmirDehghani wrote: Sun May 21, 2017 12:38 am Thanks Master
What is the Category ? (rsi,stoch,macd, ... or ?)
As its name states : macd

Re: Does this indicator repaint?

Posted: Thu May 25, 2017 11:54 pm
by zzleepy
I'm wondering about the nature of how this indicator paints. Does it repaint, and if not, when it does paint how many bars back does it paint?

Re: Does this indicator repaint?

Posted: Fri May 26, 2017 12:19 am
by mladen
zzleepy wrote: Thu May 25, 2017 11:54 pm I'm wondering about the nature of how this indicator paints. Does it repaint, and if not, when it does paint how many bars back does it paint?
Since the nature of it is in the high/low channel (that is drawn on the chart too), if the new highest high or lowest low for the chose period is formed, then the extreme can change. It will not change the direction of the last leg, but will change the position of the last extreme. It can do that for the high/low period bars back

Re: Does this indicator repaint?

Posted: Thu Jun 15, 2017 5:49 am
by yuhu
Hi all, does this indi repaint? Seems to be simple enough not to repaint and it uses i+1. Would appreciate your help in confirming.

Many thanks in advance!

Code: Select all

//+------------------------------------------------------------------+
//|                                                TradeBreakOut.mq4 |
//|                                  Copyright © 2013, Andriy Moraru |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.earnforex.com"
/*
Red line crossing 0 from above is a support breakout signal.
Green line crossing 0 from below is a resistance breakout signal.
*/
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_color1 Green
#property indicator_color2 Red
//---
extern int L=50; // Period
extern ENUM_APPLIED_PRICE PriceTypeHigh=PRICE_HIGH;
extern ENUM_APPLIED_PRICE PriceTypeLow =PRICE_LOW; 
extern ENUM_MA_METHOD     AverageMethod=MODE_SMA;
extern int                AveragePeriod=5;
//--- Buffers
double TBR_R[],TBR_S[],priceh[],pricel[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   SetIndexBuffer(0,TBR_R);
   SetIndexBuffer(1,TBR_S);
   SetIndexBuffer(2,priceh);
   SetIndexBuffer(3,pricel);
//---
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
//---
   SetIndexDrawBegin(0,L);
   SetIndexDrawBegin(1,L);
//---
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexEmptyValue(1,EMPTY_VALUE);
//---
   IndicatorDigits(Digits);
//---
   IndicatorShortName("TBR("+L+")");
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| TradeBreakOut                                                    |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars <= L) return(0);
//---
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
//--- Skip calculated bars
   int end=Bars-counted_bars;
//--- Cannot calculate bars that are too close to the end. There won't be enough bars to calculate ArrayMin/Max
   if(Bars-end<=L) end=Bars -(L+1);
//---

   for(int i=0; i<end; i++)
     {
      double th = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeHigh,i);
      double tl = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeLow,i);
      priceh[i] = MathMax(th,tl);
      pricel[i] = MathMin(th,tl);
    }      
   for(i=0; i<end; i++)
     {
      
         double max = priceh[ArrayMaximum(priceh, L, i + 1)];
         double min = pricel[ArrayMinimum(pricel, L, i + 1)];
         TBR_R[i] = (max!=0) ? (priceh[i] - priceh[ArrayMaximum(priceh, L, i + 1)]) / max : 0;
         TBR_S[i] = (min!=0) ? (pricel[i] - pricel[ArrayMinimum(pricel, L, i + 1)]) / min : 0;
     }
//---
   return(0);
  }
//+------------------------------------------------------------------+

Re: Does this indicator repaint?

Posted: Fri Jun 16, 2017 12:55 am
by mladen
yuhu wrote: Thu Jun 15, 2017 5:49 am Hi all, does this indi repaint? Seems to be simple enough not to repaint and it uses i+1. Would appreciate your help in confirming.

Many thanks in advance!

Code: Select all

//+------------------------------------------------------------------+
//|                                                TradeBreakOut.mq4 |
//|                                  Copyright © 2013, Andriy Moraru |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.earnforex.com"
/*
Red line crossing 0 from above is a support breakout signal.
Green line crossing 0 from below is a resistance breakout signal.
*/
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_color1 Green
#property indicator_color2 Red
//---
extern int L=50; // Period
extern ENUM_APPLIED_PRICE PriceTypeHigh=PRICE_HIGH;
extern ENUM_APPLIED_PRICE PriceTypeLow =PRICE_LOW; 
extern ENUM_MA_METHOD     AverageMethod=MODE_SMA;
extern int                AveragePeriod=5;
//--- Buffers
double TBR_R[],TBR_S[],priceh[],pricel[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   SetIndexBuffer(0,TBR_R);
   SetIndexBuffer(1,TBR_S);
   SetIndexBuffer(2,priceh);
   SetIndexBuffer(3,pricel);
//---
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
//---
   SetIndexDrawBegin(0,L);
   SetIndexDrawBegin(1,L);
//---
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexEmptyValue(1,EMPTY_VALUE);
//---
   IndicatorDigits(Digits);
//---
   IndicatorShortName("TBR("+L+")");
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| TradeBreakOut                                                    |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars <= L) return(0);
//---
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
//--- Skip calculated bars
   int end=Bars-counted_bars;
//--- Cannot calculate bars that are too close to the end. There won't be enough bars to calculate ArrayMin/Max
   if(Bars-end<=L) end=Bars -(L+1);
//---

   for(int i=0; i<end; i++)
     {
      double th = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeHigh,i);
      double tl = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeLow,i);
      priceh[i] = MathMax(th,tl);
      pricel[i] = MathMin(th,tl);
    }      
   for(i=0; i<end; i++)
     {
      
         double max = priceh[ArrayMaximum(priceh, L, i + 1)];
         double min = pricel[ArrayMinimum(pricel, L, i + 1)];
         TBR_R[i] = (max!=0) ? (priceh[i] - priceh[ArrayMaximum(priceh, L, i + 1)]) / max : 0;
         TBR_S[i] = (min!=0) ? (pricel[i] - pricel[ArrayMinimum(pricel, L, i + 1)]) / min : 0;
     }
//---
   return(0);
  }
//+------------------------------------------------------------------+
It does not repaint
In any case you can use this instead (it is a bit faster)

Code: Select all

//+------------------------------------------------------------------+
//|                                                TradeBreakOut.mq4 |
//|                                  Copyright © 2013, Andriy Moraru |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.earnforex.com"
/*
Red line crossing 0 from above is a support breakout signal.
Green line crossing 0 from below is a resistance breakout signal.
*/
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_color1 Green
#property indicator_color2 Red
//---
extern int L=50; // Period
extern ENUM_APPLIED_PRICE PriceTypeHigh=PRICE_HIGH;
extern ENUM_APPLIED_PRICE PriceTypeLow =PRICE_LOW; 
extern ENUM_MA_METHOD     AverageMethod=MODE_SMA;
extern int                AveragePeriod=5;
//--- Buffers
double TBR_R[],TBR_S[],priceh[],pricel[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   SetIndexBuffer(0,TBR_R);
   SetIndexBuffer(1,TBR_S);
   SetIndexBuffer(2,priceh);
   SetIndexBuffer(3,pricel);
   IndicatorDigits(Digits);
   IndicatorShortName("TBR("+L+")");
   return(0);
}
int start()
{
   if(Bars <= L) return(0);
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
//--- Skip calculated bars
   int end=Bars-counted_bars;
//--- Cannot calculate bars that are too close to the end. There won't be enough bars to calculate ArrayMin/Max
   if(Bars-end<=L) end=Bars -(L+1);
//---
   Comment(end);
   for(int i=end; i>=0; i--)
   {
      double th = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeHigh,i);
      double tl = iMA(NULL,0,AveragePeriod,0,AverageMethod,PriceTypeLow,i);
      priceh[i] = MathMax(th,tl);
      pricel[i] = MathMin(th,tl);
      double max = priceh[ArrayMaximum(priceh, L, i + 1)];
      double min = pricel[ArrayMinimum(pricel, L, i + 1)];
      TBR_R[i] = (max!=0) ? (priceh[i] - priceh[ArrayMaximum(priceh, L, i + 1)]) / max : 0;
      TBR_S[i] = (min!=0) ? (pricel[i] - pricel[ArrayMinimum(pricel, L, i + 1)]) / min : 0;
   }
   return(0);
}

Re: Does this indicator repaint?

Posted: Fri Jun 16, 2017 6:34 am
by yuhu
many thanks Mladen as always! :)

Re: Does this indicator repaint?

Posted: Tue Jul 11, 2017 1:33 am
by Sanni123
Does this repaint?
Thanks

Re: Does this indicator repaint?

Posted: Tue Jul 11, 2017 1:35 am
by mladen
Sanni123 wrote: Tue Jul 11, 2017 1:33 am Does this repaint?
Thanks
In short, with default parameters : yes

Re: Does this indicator repaint?

Posted: Tue Jul 11, 2017 3:08 am
by Sanni123
mladen wrote: Tue Jul 11, 2017 1:35 am In short, with default parameters : yes
Thanks Mladen for reply,
If you have the time could you please elaborate
how I can change parameters so its non repainting to see how much different it is when lines crossover.

Re: Does this indicator repaint?

Posted: Tue Jul 11, 2017 3:44 am
by mladen
Sanni123 wrote: Tue Jul 11, 2017 3:08 am Thanks Mladen for reply,
If you have the time could you please elaborate
how I can change parameters so its non repainting to see how much different it is when lines crossover.
Set the ignore future to true
But I guess that then you are not going to like the results