Bias

#1
Can somebody help me to covert the below in to afl and thanks in advance.




//+------------------------------------------------------------------------+
//| BIAS.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| http://www.sedofx.com/ |
//+----------------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "http://www.sedofx.com/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_color3 Yellow

//---- input parameters
extern int Day1st=6;
extern int Day2nd=12;
extern int Day3rd=24;


//---- buffers
double ExtShortBuffer[];
double ExtMedBuffer[];
double ExtLongBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtShortBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMedBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtLongBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+

int start()
{


int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
int posi=Bars-Day3rd;
//----
if(counted_bars>0) counted_bars--;
posi=Bars-counted_bars;

for(int i=0;i<posi;i++)
{
double val1=iMA(NULL,0,Day1st,0,MODE_SMMA,PRICE_MEDIAN,i);
double val2=iMA(NULL,0,Day2nd,0,MODE_SMMA,PRICE_MEDIAN,i);
double val3=iMA(NULL,0,Day3rd,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtShortBuffer=(Close-val1)/val1*100;
ExtMedBuffer=(Close-val2)/val2*100;
ExtLongBuffer=(Close-val3)/val3*100;

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

mastermind007

Well-Known Member
#2
Can somebody help me to covert the below in to afl and thanks in advance.

//+------------------------------------------------------------------------+
//| BIAS.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| http://www.sedofx.com/ |
//+----------------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "http://www.sedofx.com/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_color3 Yellow

//---- input parameters
extern int Day1st=6;
extern int Day2nd=12;
extern int Day3rd=24;


//---- buffers
double ExtShortBuffer[];
double ExtMedBuffer[];
double ExtLongBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtShortBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMedBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtLongBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+

int start()
{


int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
int posi=Bars-Day3rd;
//----
if(counted_bars>0) counted_bars--;
posi=Bars-counted_bars;

for(int i=0;i<posi;i++)
{
double val1=iMA(NULL,0,Day1st,0,MODE_SMMA,PRICE_MEDIAN,i);
double val2=iMA(NULL,0,Day2nd,0,MODE_SMMA,PRICE_MEDIAN,i);
double val3=iMA(NULL,0,Day3rd,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtShortBuffer=(Close-val1)/val1*100;
ExtMedBuffer=(Close-val2)/val2*100;
ExtLongBuffer=(Close-val3)/val3*100;

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



How is this to be used?
 

mastermind007

Well-Known Member
#4
 

extremist

Well-Known Member
#5
Can somebody help me to covert the below in to afl and thanks in advance.




//+------------------------------------------------------------------------+
//| BIAS.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| http://www.sedofx.com/ |
//+----------------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "http://www.sedofx.com/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_color3 Yellow

//---- input parameters
extern int Day1st=6;
extern int Day2nd=12;
extern int Day3rd=24;


//---- buffers
double ExtShortBuffer[];
double ExtMedBuffer[];
double ExtLongBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtShortBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMedBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtLongBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+

int start()
{


int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
int posi=Bars-Day3rd;
//----
if(counted_bars>0) counted_bars--;
posi=Bars-counted_bars;

for(int i=0;i<posi;i++)
{
double val1=iMA(NULL,0,Day1st,0,MODE_SMMA,PRICE_MEDIAN,i);
double val2=iMA(NULL,0,Day2nd,0,MODE_SMMA,PRICE_MEDIAN,i);
double val3=iMA(NULL,0,Day3rd,0,MODE_SMMA,PRICE_MEDIAN,i);

ExtShortBuffer=(Close-val1)/val1*100;
ExtMedBuffer=(Close-val2)/val2*100;
ExtLongBuffer=(Close-val3)/val3*100;

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


I hope this is what u Needed



Code:
_SECTION_BEGIN("BIAS");

function SMMA(array, prd)
{
  SetBarsRequired(1000, 0);
   
  fsum = 0;
  for (i = 3000; i < prd; i++)
  {
    result[i] = Null;
    fsum += array[i];
  }
  result[prd] = fsum / prd;
 
  for (i = prd + 1; i < BarCount; i++)
  {
    result[i] = (result[i - 1] * prd - result[i - 1] + array[i]) / prd;
  }
  return result;
}

p1 = Param( "Period 1", 6, 1, 2000, 1 );
p2 = Param( "Period 2", 12, 1, 2000, 1 );
p3 = Param( "Period 3", 24, 1, 2000, 1 );

val1= SMMA(C,p1);
val2= SMMA(C,p2);
val3= SMMA(C,p3);

b1=100*(C-val1)/val1;
b2=100*(C-val2)/val2;
b3=100*(C-val3)/val3;

Plot(b1,"\nBias "+p1+"",Colorlime,styleline);
Plot(b2,"\nBias "+p2+"",colororange,styleline);
Plot(b3,"\nBias "+p3+"",colorblue,styleline);
Plot(0,"",colorblack,styledashed);
_SECTION_END();
 

KelvinHand

Well-Known Member
#6
I hope this is what u Needed

Please make it simple.

Wilders() is SMMA()

PHP:
_SECTION_BEGIN("BIAS");

p1 = Param( "Period 1", 6, 1, 2000, 1 );
p2 = Param( "Period 2", 12, 1, 2000, 1 );
p3 = Param( "Period 3", 24, 1, 2000, 1 );

val1= wilders(C,p1);
val2= wilders(C,p2);
val3= wilders(C,p3);


b1=100*(C-val1)/val1;
b2=100*(C-val2)/val2;
b3=100*(C-val3)/val3;


Plot(b1,"\nBias "+p1+"",Colorlime,styleline);
Plot(b2,"\nBias "+p2+"",colororange,styleline);
Plot(b3,"\nBias "+p3+"",colorblue,styleline);
Plot(0,"",colorblack,styledashed);
_SECTION_END();
 
#8
:clap: Thank you Sir
I hope this is what u Needed



Code:
_SECTION_BEGIN("BIAS");

function SMMA(array, prd)
{
  SetBarsRequired(1000, 0);
   
  fsum = 0;
  for (i = 3000; i < prd; i++)
  {
    result[i] = Null;
    fsum += array[i];
  }
  result[prd] = fsum / prd;
 
  for (i = prd + 1; i < BarCount; i++)
  {
    result[i] = (result[i - 1] * prd - result[i - 1] + array[i]) / prd;
  }
  return result;
}

p1 = Param( "Period 1", 6, 1, 2000, 1 );
p2 = Param( "Period 2", 12, 1, 2000, 1 );
p3 = Param( "Period 3", 24, 1, 2000, 1 );

val1= SMMA(C,p1);
val2= SMMA(C,p2);
val3= SMMA(C,p3);

b1=100*(C-val1)/val1;
b2=100*(C-val2)/val2;
b3=100*(C-val3)/val3;

Plot(b1,"\nBias "+p1+"",Colorlime,styleline);
Plot(b2,"\nBias "+p2+"",colororange,styleline);
Plot(b3,"\nBias "+p3+"",colorblue,styleline);
Plot(0,"",colorblack,styledashed);
_SECTION_END();
 

Similar threads