Dynamice zone MACD ---CAN ANY ONE CONVERT INTO AFL...????

rocky01

Active Member
#23
Sir kindly share dynamic macd and add plz I have no option to download it so I request you to post it on the thread it self so that I can copy.thanks
 
#24
hi and thanks for this forum, master programmer , this is dynamic rsi code for mt4 , can anyone convert this code to amibroker please .i tried to convert dzbuy function but this not work and dont plot . whats wrong , thanks for your help , brother klevinhand and others good programmers please look at this , i appreciate that very much thanks

this is mt4 code

Code:
//+------------------------------------------------------------------+
//|                                        dynamic zone smoothed rsi |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "[email protected]"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  DeepSkyBlue
#property indicator_color2  LimeGreen
#property indicator_color3  Red
#property indicator_width1  2
#property indicator_minimum 0
#property indicator_maximum 100

//
//
//
//
//

extern int    RsiLength              = 9;
extern int    RsiPrice               = PRICE_CLOSE;
extern int    DzLookBackBars         = 70;
extern double DzStartBuyProbability  = 0.10;
extern double DzStartSellProbability = 0.10;

//
//
//
//
//

double rsi[];
double bli[];
double sli[];

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

int init()
{
   SetIndexBuffer(0,rsi);
   SetIndexBuffer(1,bli);
   SetIndexBuffer(2,sli);

   //
   //
   //
   //
   //
   
   string PriceType;
      switch(RsiPrice)
      {
         case PRICE_CLOSE:    PriceType = "Close";    break;  // 0
         case PRICE_OPEN:     PriceType = "Open";     break;  // 1
         case PRICE_HIGH:     PriceType = "High";     break;  // 2
         case PRICE_LOW:      PriceType = "Low";      break;  // 3
         case PRICE_MEDIAN:   PriceType = "Median";   break;  // 4
         case PRICE_TYPICAL:  PriceType = "Typical";  break;  // 5
         case PRICE_WEIGHTED: PriceType = "Weighted"; break;  // 6
      }      

   //
   //
   //
   //
   //

   RsiLength = MathMax(RsiLength ,1);
   IndicatorShortName ("Dynamic zone RSI ("+RsiLength+","+PriceType+","+DzLookBackBars+","+DoubleToStr(DzStartBuyProbability,3)+","+DoubleToStr(DzStartSellProbability,3)+")");
   return(0);
}
int deinit()
{
   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);

   //
   //
   //
   //
   //
   //

   for(i=limit; i >= 0; i--)
   {
      rsi[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
      bli[i] = dzBuy (i, rsi, DzStartBuyProbability,  DzLookBackBars);
      sli[i] = dzSell(i, rsi, DzStartSellProbability, DzLookBackBars);
   }
   return(0);
}

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

double dzBuy(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]<yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}

//
//
//
//
//

double dzSell(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]>yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}
and this is my try to convert dz buy function code to ami , and perhaps wrong , thanks please help

Code:
function dzBuy(arrey,initValue,lookBackBars)
{
	left  = -10000;
	right =  10000;
	eps      = 0.001;
	yval     = (left+right)/2.0;
	delta    = yval-left;
	maxSteps = 0;


	while (delta>0.005  AND  maxSteps<50)
	{
		maxSteps++;
		count = 0;

		for (k=0; k<lookBackBars ;k++)   

		if (arrey[k]<yval) 
		count++;
		
		prob = count/lookBackBars;
		
		if (prob>(initValue+eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}                  
		if (prob<(initValue-eps))
		{
			left = yval;
			yval = (yval+right)/2.0;
		}
		if (prob<(initValue+eps) && prob>(initValue-eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}
		
		delta=yval-left;
	}               
	return(yval);   
}

Plot(	dzBuy(RSI(),0.1,70),"",colorGreen,styleLine);
 

Attachments

extremist

Well-Known Member
#25
To better understand dynamic zones, let�s first describe them mathematically and then explain their use. The dynamic zones definition:
Find V such that:
For dynamic zone buy: P{X <= V}=P1

For dynamic zone sell: P{X >= V}=P2
where P1 and P2 are the probabilities set by the trader, X is the value of the indicator for the selected period and V represents the value of the dynamic zone.
The probability input P1 and P2 can be adjusted by the trader to encompass as much or as little data as the trader would like. The smaller the probability, the fewer data values above and below the dynamic zones. This translates into a wider range between the buy and sell zones. If a 10% probability is used for P1 and P2, only those data values that make up the top 10% and bottom 10% for an indicator are used in the construction of the zones. Of the values, 80% will fall between the two extreme levels. Because dynamic zone levels are penetrated so infrequently, when this happens, traders know that the market has truly moved into overbought or oversold territory.

CALCULATING THE DYNAMIC ZONES

The algorithm for the dynamic zones is a series of steps. First, decide the value of the lookback period t. Next, decide the value of the probability Pbuy for buy zone and value of the probability Psell for the sell zone.

For i=1, to the last lookback period, build the distribution f(x) of the price during the lookback period i. Then find the value Vi1 such that the probability of the price less than or equal to Vi1 during the lookback period i is equal to Pbuy. Find the value Vi2 such that the probability of the price greater or equal to Vi2 during the lookback period i is equal to Psell. The sequence of Vi1 for all periods gives the buy zone. The sequence of Vi2 for all periods gives the sell zone.

In the algorithm description, we have: �Build the distribution f(x) of the price during the lookback period i.� The distribution here is empirical � namely, how many times a given value of x appeared during the lookback period. The problem is to find such x that the probability of a price being
greater or equal to x will be equal to a probability selected by the user. Probability is the area under the distribution curve. The task is to find such value of x that the area under the distribution curve to the right of x will be equal to the probability selected by the user. That x is the dynamic zone.

taken from : https://www.forex-tsd.com/forum/exclusive/11725-dynamic-zone-indicators

but still no clue....
 
#27
hi and thanks for this forum, master programmer , this is dynamic rsi code for mt4 , can anyone convert this code to amibroker please .i tried to convert dzbuy function but this not work and dont plot . whats wrong , thanks for your help , brother klevinhand and others good programmers please look at this , i appreciate that very much thanks

this is mt4 code

Code:
//+------------------------------------------------------------------+
//|                                        dynamic zone smoothed rsi |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "[email protected]"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  DeepSkyBlue
#property indicator_color2  LimeGreen
#property indicator_color3  Red
#property indicator_width1  2
#property indicator_minimum 0
#property indicator_maximum 100

//
//
//
//
//

extern int    RsiLength              = 9;
extern int    RsiPrice               = PRICE_CLOSE;
extern int    DzLookBackBars         = 70;
extern double DzStartBuyProbability  = 0.10;
extern double DzStartSellProbability = 0.10;

//
//
//
//
//

double rsi[];
double bli[];
double sli[];

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

int init()
{
   SetIndexBuffer(0,rsi);
   SetIndexBuffer(1,bli);
   SetIndexBuffer(2,sli);

   //
   //
   //
   //
   //
   
   string PriceType;
      switch(RsiPrice)
      {
         case PRICE_CLOSE:    PriceType = "Close";    break;  // 0
         case PRICE_OPEN:     PriceType = "Open";     break;  // 1
         case PRICE_HIGH:     PriceType = "High";     break;  // 2
         case PRICE_LOW:      PriceType = "Low";      break;  // 3
         case PRICE_MEDIAN:   PriceType = "Median";   break;  // 4
         case PRICE_TYPICAL:  PriceType = "Typical";  break;  // 5
         case PRICE_WEIGHTED: PriceType = "Weighted"; break;  // 6
      }      

   //
   //
   //
   //
   //

   RsiLength = MathMax(RsiLength ,1);
   IndicatorShortName ("Dynamic zone RSI ("+RsiLength+","+PriceType+","+DzLookBackBars+","+DoubleToStr(DzStartBuyProbability,3)+","+DoubleToStr(DzStartSellProbability,3)+")");
   return(0);
}
int deinit()
{
   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);

   //
   //
   //
   //
   //
   //

   for(i=limit; i >= 0; i--)
   {
      rsi[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
      bli[i] = dzBuy (i, rsi, DzStartBuyProbability,  DzLookBackBars);
      sli[i] = dzSell(i, rsi, DzStartSellProbability, DzLookBackBars);
   }
   return(0);
}

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

double dzBuy(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]<yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}

//
//
//
//
//

double dzSell(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]>yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}
and this is my try to convert dz buy function code to ami , and perhaps wrong , thanks please help

Code:
function dzBuy(arrey,initValue,lookBackBars)
{
	left  = -10000;
	right =  10000;
	eps      = 0.001;
	yval     = (left+right)/2.0;
	delta    = yval-left;
	maxSteps = 0;


	while (delta>0.005  AND  maxSteps<50)
	{
		maxSteps++;
		count = 0;

		for (k=0; k<lookBackBars ;k++)   

		if (arrey[k]<yval) 
		count++;
		
		prob = count/lookBackBars;
		
		if (prob>(initValue+eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}                  
		if (prob<(initValue-eps))
		{
			left = yval;
			yval = (yval+right)/2.0;
		}
		if (prob<(initValue+eps) && prob>(initValue-eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}
		
		delta=yval-left;
	}               
	return(yval);   
}

Plot(	dzBuy(RSI(),0.1,70),"",colorGreen,styleLine);
comon guys cant anyone help us
 
#28
hi and thanks for this forum, master programmer , this is dynamic rsi code for mt4 , can anyone convert this code to amibroker please .i tried to convert dzbuy function but this not work and dont plot . whats wrong , thanks for your help , brother klevinhand and others good programmers please look at this , i appreciate that very much thanks

this is mt4 code

Code:
//+------------------------------------------------------------------+
//|                                        dynamic zone smoothed rsi |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "[email protected]"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  DeepSkyBlue
#property indicator_color2  LimeGreen
#property indicator_color3  Red
#property indicator_width1  2
#property indicator_minimum 0
#property indicator_maximum 100

//
//
//
//
//

extern int    RsiLength              = 9;
extern int    RsiPrice               = PRICE_CLOSE;
extern int    DzLookBackBars         = 70;
extern double DzStartBuyProbability  = 0.10;
extern double DzStartSellProbability = 0.10;

//
//
//
//
//

double rsi[];
double bli[];
double sli[];

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

int init()
{
   SetIndexBuffer(0,rsi);
   SetIndexBuffer(1,bli);
   SetIndexBuffer(2,sli);

   //
   //
   //
   //
   //
   
   string PriceType;
      switch(RsiPrice)
      {
         case PRICE_CLOSE:    PriceType = "Close";    break;  // 0
         case PRICE_OPEN:     PriceType = "Open";     break;  // 1
         case PRICE_HIGH:     PriceType = "High";     break;  // 2
         case PRICE_LOW:      PriceType = "Low";      break;  // 3
         case PRICE_MEDIAN:   PriceType = "Median";   break;  // 4
         case PRICE_TYPICAL:  PriceType = "Typical";  break;  // 5
         case PRICE_WEIGHTED: PriceType = "Weighted"; break;  // 6
      }      

   //
   //
   //
   //
   //

   RsiLength = MathMax(RsiLength ,1);
   IndicatorShortName ("Dynamic zone RSI ("+RsiLength+","+PriceType+","+DzLookBackBars+","+DoubleToStr(DzStartBuyProbability,3)+","+DoubleToStr(DzStartSellProbability,3)+")");
   return(0);
}
int deinit()
{
   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);

   //
   //
   //
   //
   //
   //

   for(i=limit; i >= 0; i--)
   {
      rsi[i] = iRSI(NULL,0,RsiLength,RsiPrice,i);
      bli[i] = dzBuy (i, rsi, DzStartBuyProbability,  DzLookBackBars);
      sli[i] = dzSell(i, rsi, DzStartSellProbability, DzLookBackBars);
   }
   return(0);
}

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

double dzBuy(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]<yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}

//
//
//
//
//

double dzSell(int i, double& array[], double initValue, int lookBackBars)
{
   double left  = -10000;
   double right =  10000;
   
   if ((Bars-i)<lookBackBars) return(EMPTY_VALUE);
   
   //
   //
   //
   //
   //

   double eps      = 0.001;
   double yval     = (left+right)/2.0;
	double delta    = yval-left;
	int    maxSteps = 0;
	
		while (delta>0.005 && maxSteps<50)
		{
			maxSteps++;
   	      double count = 0;
			   for (int k=0; k<lookBackBars;k++) if (array[i+k]>yval) count++;
	
				double prob = count/lookBackBars;
               if (prob>(initValue+eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }                  
               if (prob<(initValue-eps))
               {
                  right = yval;
                  yval  = (yval+left)/2.0;
               }
               if (prob<(initValue+eps) && prob>(initValue-eps))
               {
                  left = yval;
                  yval = (yval+right)/2.0;
               }
               delta=yval-left;
      }               
      return(yval);   
}
and this is my try to convert dz buy function code to ami , and perhaps wrong , thanks please help

Code:
function dzBuy(arrey,initValue,lookBackBars)
{
	left  = -10000;
	right =  10000;
	eps      = 0.001;
	yval     = (left+right)/2.0;
	delta    = yval-left;
	maxSteps = 0;


	while (delta>0.005  AND  maxSteps<50)
	{
		maxSteps++;
		count = 0;

		for (k=0; k<lookBackBars ;k++)   

		if (arrey[k]<yval) 
		count++;
		
		prob = count/lookBackBars;
		
		if (prob>(initValue+eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}                  
		if (prob<(initValue-eps))
		{
			left = yval;
			yval = (yval+right)/2.0;
		}
		if (prob<(initValue+eps) && prob>(initValue-eps))
		{
			right = yval;
			yval  = (yval+left)/2.0;
		}
		
		delta=yval-left;
	}               
	return(yval);   
}

Plot(	dzBuy(RSI(),0.1,70),"",colorGreen,styleLine);
I guess it is easy for programmers .help us guys please .my master kelvinhand where are you ?:thumb:
 
Last edited: