I need help adding a StdDev multiplier calculation to a simple histogram.
The histogram is Close[x + smoothing] - Close [x] and without my mistaken StdDev multiplier it plots fine. I want to see what it looks like by multiplying the StdDev for each bar to the histogram calc.
Here is the code with the calc added which is: *iStdDevOnArray(CloseBuffer,0,30,0,0,0)
by deleting *iStdDevOnArray(CloseBuffer,0,30,0,0,0) it works fine but I want to experiment with adding the StdDev multiplier to the simple calculation
Can anyone help with this. Thank you.
The histogram is Close[x + smoothing] - Close [x] and without my mistaken StdDev multiplier it plots fine. I want to see what it looks like by multiplying the StdDev for each bar to the histogram calc.
Here is the code with the calc added which is: *iStdDevOnArray(CloseBuffer,0,30,0,0,0)
by deleting *iStdDevOnArray(CloseBuffer,0,30,0,0,0) it works fine but I want to experiment with adding the StdDev multiplier to the simple calculation
Can anyone help with this. Thank you.
Inserted Code
***********************************
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//----- input parameters
extern int LookBackPeriod = 12;
extern int MaxBarsForComputation = 500;
//----- buffers
double Up[];
double Dn[];
double CloseBuffer[];
//-----
int init()
{
IndicatorBuffers(3);
SetIndexStyle(0, DRAW_HISTOGRAM,0,2);
SetIndexBuffer(0, Up);
SetIndexStyle(1, DRAW_HISTOGRAM,0,2);
SetIndexBuffer(1, Dn);
SetIndexStyle(2, DRAW_NONE);
SetIndexBuffer(2, CloseBuffer,INDICATOR_CALCULATIONS);
//-----
IndicatorDigits(Digits);
string short_name = "xDev (" + LookBackPeriod + ")";
IndicatorShortName(short_name);
return(0);
}
//-----
int start()
{
int i;
if(Bars <= LookBackPeriod + 1)
return(0);
int counted_bars = MaxBarsForComputation;
int limit = Bars - counted_bars;
if(counted_bars > 0)
limit++;
for(i = 0; i < limit; i++)
{
CloseBuffer[i] = Close[i];
if (Close[i+1] > Close[i+LookBackPeriod]) {Up[i] = (Close[i+1]- Close[i+LookBackPeriod])*iStdDevOnArray(CloseBuffer,0,30,0,0,0); Dn[i]=EMPTY_VALUE;}
if (Close[i+1] < Close[i+LookBackPeriod]) {Dn[i] = (Close[i+LookBackPeriod]- Close[i+1])*iStdDevOnArray(CloseBuffer,0,30,0,0,0)*-1.0; Up[i]=EMPTY_VALUE;}
}
return(0);
}
//+------------------------------------------------------------------+