새로운 지표와 McGinley 자신의 기사에 감사드립니다. 아직 읽고 있습니다. 네, 저도 처음에 9-EMA 옆에 첫 번째 버전을 놓았을 때 그 유사성에 놀랐습니다. 예, Metastock 공식은 McGinley의 공식과 유사하지 않습니다. 잘못된 정보 죄송합니다만 인터넷에서 가져온 것입니다.
적어도 지금 우리는 Investopedia 기사가 그것을 조금 과장했다는 것을 알고 있습니다. 그러나 그것은 정말로 꽤 알려지지 않았고 그것이 약간의 관심을 불러 일으켰고 전체적으로 재미있었습니다.
linuxuser가 게시한 볼린저 %b 표시기를 (추가) 수정하려고 합니다. 하나의 그래프에 여러 기간을 표시할 수 있을 뿐만 아니라 신호선이 있는 스토캐스틱과 유사한 방식으로 동작하도록 하려고 합니다. 이전에 linuxuser의 도움으로 이 작업을 처리했으므로 현재 동일한 창에 두 개 또는 세 개의 마침표를 표시하도록 설정했습니다.
이제 계산에서 표준 편차 에 대한 분수 값을 사용할 수 있도록 만들려고 합니다. 표준 iBands 기능을 사용할 수 없다고 생각하는 것이 맞습니까? 표준 밴드 표시기에 제공된 코드를 사용해 보았지만 많은 성공을 거두지 못했습니다. 누군가 저를 도와주시겠습니까?
나는 또한 다른 시간 프레임에서 지표 표시 계산을 할 수 있기를 희망하지만 한 번에 한 단계씩 추측합니다. 나는 이것이 처음 생각했던 것보다 조금 어려울 수 있다는 것을 깨달았습니다.
당신이 맞습니다. 내장된 볼린저 밴드 표시기는 표준 편차 승수의 정수 값에 대해서만 작동합니다. 여기에 분수 승수와 다중 편차를 사용할 수 있는 간단한 것이 있습니다. 도움이 될 수 있습니다.
더 어려운 것처럼 : 코딩을 포기하지 마십시오. 코딩하려는 작업을 완료하면 다음이 표시됩니다.
문안 인사
믈라덴
whitebloodcell: linuxuser가 게시한 볼린저 %b 표시기를 (추가) 수정하려고 합니다. 하나의 그래프에 여러 기간을 표시할 수 있을 뿐만 아니라 신호선이 있는 스토캐스틱과 유사한 방식으로 동작하도록 하려고 합니다. 이전에 linuxuser의 도움으로 이 작업을 처리했으므로 현재 동일한 창에 두 개 또는 세 개의 마침표를 표시하도록 설정했습니다.
이제 계산에서 표준 편차에 대한 분수 값을 사용할 수 있도록 만들려고 합니다. 표준 iBands 기능을 사용할 수 없다고 생각하는 것이 맞습니까? 표준 밴드 표시기에 제공된 코드를 사용해 보았지만 많은 성공을 거두지 못했습니다. 누군가 저를 도와 주시겠습니까?
나는 또한 다른 시간 프레임에서 지표 표시 계산을 할 수 있기를 희망하지만 한 번에 한 단계씩 추측합니다. 나는 이것이 처음 생각했던 것보다 조금 어려울 수 있다는 것을 깨달았습니다.
...
문서,
2개의 버퍼가 모두 사용됨(그래서 6개가 더 남음)
나는 당신이 히스토를 어떻게 원하는지 정확히 알지 못하므로 대신 이것을 게시하십시오(히스토 없음, 어느 시점에서 경고가 추가 되었으며 이름에 "짧은"과 "긴"을 쓰지 않습니다) 필요하면 소리를 질러 역사에 도움
문안 인사
믈라덴
하이 믈라덴,
히스토 바에 이 인디를 올릴 기회가 있는지 알려주실 수 있나요?
모든 버퍼가 바쁘고 수정하는 방법을 모르겠습니다 ...
여기 좀 도와주세요
모두에게 감사 드려요.
친애하는
문서mladen 감사합니다!
너 굉장하다 ! 짧은 시간에 얼마나 환상적인 코드인가!
나에게 너무 환상적입니다 ... 내 표준 지식과 완전히 다르기 때문에 수정하는 방법에 대해 약간 혼란 스럽습니다.
이 두 라인의 교차를 위한 히스토 바를 갖고 싶습니다: 트리거 라인이 있는 에르고딕 cci 라인
친애하는
문서
...
두 가지 버전:
"고전 역사" - 첫 번째 하위 창
"Bars histo" -> 원하는 것 - 벨로우즈 ergodic CCI 트리거 시 녹색, ergodic CCI 이상 트리거 시 빨간색, (만약) 동일하면 회색
문안 인사
믈라덴
mladen 감사합니다!
너 굉장하다 ! 짧은 시간에 얼마나 환상적인 코드인가!
나에게 너무 환상적입니다 ... 내 표준 지식과 완전히 다르기 때문에 수정하는 방법에 대해 약간 혼란 스럽습니다.
이 두 라인의 교차를 위한 히스토 바를 갖고 싶습니다: 트리거 라인이 있는 에르고딕 cci 라인
친애하는
문서두 가지 버전:
"고전 역사" - 첫 번째 하위 창
"Bars histo" -> 원하는 것 - 벨로우즈 ergodic CCI 트리거 시 녹색, ergodic CCI 이상 트리거 시 빨간색, (만약) 동일하면 회색
문안 인사
믈라덴내가 필요로 하는 바로 그것!
감사합니다 mladen 당신은 천재입니다!
친애하는
문서
안녕하세요 mladen님
오늘 오후에 잠시 들러 인사를 나누기 전에 서둘러야 합니다.
새로운 지표와 McGinley 자신의 기사에 감사드립니다. 아직 읽고 있습니다. 네, 저도 처음에 9-EMA 옆에 첫 번째 버전을 놓았을 때 그 유사성에 놀랐습니다. 예, Metastock 공식은 McGinley의 공식과 유사하지 않습니다. 잘못된 정보 죄송합니다만 인터넷에서 가져온 것입니다.
적어도 지금 우리는 Investopedia 기사가 그것을 조금 과장했다는 것을 알고 있습니다. 그러나 그것은 정말로 꽤 알려지지 않았고 그것이 약간의 관심을 불러 일으켰고 전체적으로 재미있었습니다.
감사합니다 & 안부 인사,
즈와이.
미안 mladen,
이 마지막 부분에서 저를 도와주시겠습니까?
회색과 노란색 선이 없고 막대가 모두 같은 행에 있는 이 색상을 (그림과 같이) 가질 수 있습니까?
친애하는
문서
...
이와 같이 ?
문안 인사
믈라덴
미안 mladen,
이 마지막 부분에서 저를 도와주시겠습니까?
회색과 노란색 선이 없고 막대가 모두 같은 행에 있는 이 색상을 (그림과 같이) 가질 수 있습니까?
친애하는
문서이와 같이 ?
문안 인사
믈라덴바로 그거죠 !
많은 감사 mladen ... 당신에게 좋은 핍스
문안 인사
문서
linuxuser가 게시한 볼린저 %b 표시기를 (추가) 수정하려고 합니다. 하나의 그래프에 여러 기간을 표시할 수 있을 뿐만 아니라 신호선이 있는 스토캐스틱과 유사한 방식으로 동작하도록 하려고 합니다. 이전에 linuxuser의 도움으로 이 작업을 처리했으므로 현재 동일한 창에 두 개 또는 세 개의 마침표를 표시하도록 설정했습니다.
이제 계산에서 표준 편차 에 대한 분수 값을 사용할 수 있도록 만들려고 합니다. 표준 iBands 기능을 사용할 수 없다고 생각하는 것이 맞습니까? 표준 밴드 표시기에 제공된 코드를 사용해 보았지만 많은 성공을 거두지 못했습니다. 누군가 저를 도와주시겠습니까?
나는 또한 다른 시간 프레임에서 지표 표시 계산을 할 수 있기를 희망하지만 한 번에 한 단계씩 추측합니다. 나는 이것이 처음 생각했던 것보다 조금 어려울 수 있다는 것을 깨달았습니다.
미리 감사드립니다!
//| Bollinger %b - Multi.mq4 |
//| based on Bollinger Bands %b.mq4 |
//| Original indicator by Alejandro Galindo |
//| Modified and Corrected by Linuxser for forex TSD |
//| Further modifications made by whitebloodcell |
//|
//| John Bollinger original formula is: |
//| (Last - Lower BB)/(Upper BB - Lower BB) |
//+-------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 LightSalmon
#property indicator_color2 LightSalmon
#property indicator_color3 SkyBlue
#property indicator_color4 SkyBlue
#property indicator_color5 Green
#property indicator_color6 Green
//---- input parameters
extern bool ShowBand1 = TRUE;
extern int Timeframe_1 = 15;
extern int BBPeriod_1=5;
extern double StdDeviation_1=1.9;
extern int MainLineMAPeriod_1=1;
extern int MainLineMAMethod_1=1;
extern int SignalMAPeriod_1=2;//corresponds to %D - the signal line
extern int SignalMAMethod_1=1;
extern bool ShowBand2 = TRUE;
extern int Timeframe_2 = 15;
extern int BBPeriod_2=10;
extern double StdDeviation_2=2;
extern int MainLineMAPeriod_2=2;
extern int MainLineMAMethod_2=1;
extern int SignalMAPeriod_2=3;
extern int SignalMAMethod_2=1;
extern bool ShowBand3 = TRUE;
extern int Timeframe_3 = 15;
extern int BBPeriod_3=20;
extern double StdDeviation_3=2.0;
extern int MainLineMAPeriod_3=2;
extern int MainLineMAMethod_3=1;
extern int SignalMAPeriod_3=3;
extern int SignalMAMethod_3=1;
extern int AppliedPrice=0;
extern string s2 = "0=SMA,1=EMA,2=Smoothed,4=LWMA";
extern string s1 = "0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted";
//---- buffers
double BLG_Buffer_1[];
double MainLineBuffer_1[];
double SignalBuffer_1[];
double BLG_Buffer_2[];
double MainLineBuffer_2[];
double SignalBuffer_2[];
double BLG_Buffer_3[];
double MainLineBuffer_3[];
double SignalBuffer_3[];
//#include
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
string short_name;
SetIndexStyle(0,DRAW_LINE,EMPTY,2);
SetIndexBuffer(0,MainLineBuffer_1);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(1,SignalBuffer_1);
SetIndexStyle(2,DRAW_LINE,EMPTY,2);
SetIndexBuffer(2,MainLineBuffer_2);
SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(3,SignalBuffer_2);
SetIndexStyle(4,DRAW_LINE,EMPTY,2);
SetIndexBuffer(4,MainLineBuffer_3);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(5,SignalBuffer_3);
//SetLevelValue(1,10);
SetLevelValue(0,0);
SetLevelValue(1,20);
SetLevelValue(2,40);
SetLevelValue(3,60);
SetLevelValue(4,80);
SetLevelValue(5,100);
SetLevelStyle(STYLE_DOT,1,DimGray);
SetIndexDrawBegin(0,BBPeriod_1);
SetIndexDrawBegin(1,BBPeriod_1+SignalMAPeriod_1);
SetIndexDrawBegin(2,BBPeriod_2);
SetIndexDrawBegin(3,BBPeriod_2+SignalMAPeriod_2);
SetIndexDrawBegin(4,BBPeriod_3);
SetIndexDrawBegin(5,BBPeriod_3+SignalMAPeriod_3);
//name for DataWindow and indicator subwindow label
short_name="Bollinger Percent B (%b)("+BBPeriod_1+","+MainLineMAPeriod_1+") ("+BBPeriod_2+","+MainLineMAPeriod_2+") ("+BBPeriod_3+","+MainLineMAPeriod_3+")";
IndicatorShortName(short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
int start() {
if(ShowBand1==TRUE) {
if(Bars<=BBPeriod_1) return(0);
MainFunction(BLG_Buffer_1, MainLineBuffer_1, SignalBuffer_1, Timeframe_1, BBPeriod_1, StdDeviation_1,
AppliedPrice, MainLineMAPeriod_1, MainLineMAMethod_1, SignalMAPeriod_1, SignalMAMethod_1);
}
if(ShowBand2==TRUE) {
if(Bars<=BBPeriod_2) return(0);
MainFunction(BLG_Buffer_2, MainLineBuffer_2, SignalBuffer_2, Timeframe_2, BBPeriod_2, StdDeviation_2,
AppliedPrice, MainLineMAPeriod_2, MainLineMAMethod_2, SignalMAPeriod_2, SignalMAMethod_2);
}
if(ShowBand3==TRUE) {
if(Bars<=BBPeriod_3) return(0);
MainFunction(BLG_Buffer_3, MainLineBuffer_3, SignalBuffer_3, Timeframe_3, BBPeriod_3, StdDeviation_3,
AppliedPrice, MainLineMAPeriod_3, MainLineMAMethod_3, SignalMAPeriod_3, SignalMAMethod_3);
}
return(0);
}
//+------------------------------------------------------------------+
void MainFunction(double &BLGBuffer[], double &MainLineBuffer[], double &SignalBuffer[], int timefame, int BBPeriod, double StdDeviation,
int AppliedPrice, int MainLineMAPeriod, int MainLineMAMethod, int SignalMAPeriod, int SignalMAMethod) {
int i=0,limit=0;
double PriceArray[];
if (ArrayRange(BLGBuffer,0) != Bars) {
ArrayResize(BLGBuffer,Bars);
ArraySetAsSeries(BLGBuffer, TRUE);
}
//number of bars already processed by indicator
int counted_bars=IndicatorCounted();
//load empty values into array until enough elements for calculation
if(counted_bars<1) {
for(i=1;i<=BBPeriod;i++) {
BLGBuffer=EMPTY_VALUE;
}//end for(i=1;i<=BandsPeriod;i++)
}//end if(counted_bars<1)
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars,Bars-BBPeriod);
for(i=limit;i>=0;i--) {
//(Last - Lower BB)/(Upper BB - Lower BB)
BLGBuffer=((Close - iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i))/
(iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_UPPER,i)-iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i)))*100;
}//end for(i=limit;i>=0;i--)
//smooth the signal by applying a moving average
for (i = limit; i >= 0; i--) MainLineBuffer = iMAOnArray(BLGBuffer, 0, MainLineMAPeriod, 0, MainLineMAMethod, i);
//create a Signal line (akin to stochastics) by further smoothing the (already smoothed) signal line.
for (i = limit; i >= 0; i--) SignalBuffer = iMAOnArray(MainLineBuffer, 0, SignalMAPeriod, 0, SignalMAMethod, i);
}//end MainFunction()
//--------------------------------------------------------------------------------
//Function: BandCalculation - Not yet working
//Purpose: Calculate the value of either the upper or lower bollinger band depen-
// on input variables.
//Inputs: Mode (int) - Calculate either upper or lower band
// limit (int) - Number of bars to calculate
// timeframe (int)
// BandsPeriod (int)
// MAMethod (int)
// BandsDeviation (double)
// AppliedPrice (int)
//Returns:
//--------------------------------------------------------------------------------
/*
void BandCalculation(int Mode, int limit, int timeframe, int BandsPeriod, int MAMethod, double BandsDeviation, int AppliedPrice) {
int i,k;
double deviation;
double sum,oldval,newres;
//if(counted_bars>0) limit++;
for(i=0; i<limit; i++) {
MovingBuffer=iMA(NULL,0,BandsPeriod,BandsShift,MAMethod,AppliedPrice,i);
}//end for(i=0; i<limit; i++)
i=limit;
//i=Bars-BandsPeriod+1;
//if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
while(i>=0) {
sum=0.0;
k=i+BandsPeriod-1;
oldval=MovingBuffer;
while(k>=i) {
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}//end while(k>=i)
//calculate deviation
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
//Upper/Lower bands are equal to the moving average +/- deviation.
if(Mode==0) {
UpperBuffer=oldval+deviation;
}
else {
LowerBuffer=oldval-deviation;
}
i--;
}//end while(i>=0)
}//end start()
*/...
백혈구,
당신이 맞습니다. 내장된 볼린저 밴드 표시기는 표준 편차 승수의 정수 값에 대해서만 작동합니다. 여기에 분수 승수와 다중 편차를 사용할 수 있는 간단한 것이 있습니다. 도움이 될 수 있습니다.
더 어려운 것처럼 : 코딩을 포기하지 마십시오. 코딩하려는 작업을 완료하면 다음이 표시됩니다.
문안 인사
믈라덴
linuxuser가 게시한 볼린저 %b 표시기를 (추가) 수정하려고 합니다. 하나의 그래프에 여러 기간을 표시할 수 있을 뿐만 아니라 신호선이 있는 스토캐스틱과 유사한 방식으로 동작하도록 하려고 합니다. 이전에 linuxuser의 도움으로 이 작업을 처리했으므로 현재 동일한 창에 두 개 또는 세 개의 마침표를 표시하도록 설정했습니다.
이제 계산에서 표준 편차에 대한 분수 값을 사용할 수 있도록 만들려고 합니다. 표준 iBands 기능을 사용할 수 없다고 생각하는 것이 맞습니까? 표준 밴드 표시기에 제공된 코드를 사용해 보았지만 많은 성공을 거두지 못했습니다. 누군가 저를 도와 주시겠습니까?
나는 또한 다른 시간 프레임에서 지표 표시 계산을 할 수 있기를 희망하지만 한 번에 한 단계씩 추측합니다. 나는 이것이 처음 생각했던 것보다 조금 어려울 수 있다는 것을 깨달았습니다.
미리 감사드립니다!
//| Bollinger %b - Multi.mq4 |
//| based on Bollinger Bands %b.mq4 |
//| Original indicator by Alejandro Galindo |
//| Modified and Corrected by Linuxser for forex TSD |
//| Further modifications made by whitebloodcell |
//|
//| John Bollinger original formula is: |
//| (Last - Lower BB)/(Upper BB - Lower BB) |
//+-------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 LightSalmon
#property indicator_color2 LightSalmon
#property indicator_color3 SkyBlue
#property indicator_color4 SkyBlue
#property indicator_color5 Green
#property indicator_color6 Green
//---- input parameters
extern bool ShowBand1 = TRUE;
extern int Timeframe_1 = 15;
extern int BBPeriod_1=5;
extern double StdDeviation_1=1.9;
extern int MainLineMAPeriod_1=1;
extern int MainLineMAMethod_1=1;
extern int SignalMAPeriod_1=2;//corresponds to %D - the signal line
extern int SignalMAMethod_1=1;
extern bool ShowBand2 = TRUE;
extern int Timeframe_2 = 15;
extern int BBPeriod_2=10;
extern double StdDeviation_2=2;
extern int MainLineMAPeriod_2=2;
extern int MainLineMAMethod_2=1;
extern int SignalMAPeriod_2=3;
extern int SignalMAMethod_2=1;
extern bool ShowBand3 = TRUE;
extern int Timeframe_3 = 15;
extern int BBPeriod_3=20;
extern double StdDeviation_3=2.0;
extern int MainLineMAPeriod_3=2;
extern int MainLineMAMethod_3=1;
extern int SignalMAPeriod_3=3;
extern int SignalMAMethod_3=1;
extern int AppliedPrice=0;
extern string s2 = "0=SMA,1=EMA,2=Smoothed,4=LWMA";
extern string s1 = "0=Close,1=Open,2=High,3=Low,4=Median,5=Typical,6=Weighted";
//---- buffers
double BLG_Buffer_1[];
double MainLineBuffer_1[];
double SignalBuffer_1[];
double BLG_Buffer_2[];
double MainLineBuffer_2[];
double SignalBuffer_2[];
double BLG_Buffer_3[];
double MainLineBuffer_3[];
double SignalBuffer_3[];
//#include
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
string short_name;
SetIndexStyle(0,DRAW_LINE,EMPTY,2);
SetIndexBuffer(0,MainLineBuffer_1);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(1,SignalBuffer_1);
SetIndexStyle(2,DRAW_LINE,EMPTY,2);
SetIndexBuffer(2,MainLineBuffer_2);
SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(3,SignalBuffer_2);
SetIndexStyle(4,DRAW_LINE,EMPTY,2);
SetIndexBuffer(4,MainLineBuffer_3);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(5,SignalBuffer_3);
//SetLevelValue(1,10);
SetLevelValue(0,0);
SetLevelValue(1,20);
SetLevelValue(2,40);
SetLevelValue(3,60);
SetLevelValue(4,80);
SetLevelValue(5,100);
SetLevelStyle(STYLE_DOT,1,DimGray);
SetIndexDrawBegin(0,BBPeriod_1);
SetIndexDrawBegin(1,BBPeriod_1+SignalMAPeriod_1);
SetIndexDrawBegin(2,BBPeriod_2);
SetIndexDrawBegin(3,BBPeriod_2+SignalMAPeriod_2);
SetIndexDrawBegin(4,BBPeriod_3);
SetIndexDrawBegin(5,BBPeriod_3+SignalMAPeriod_3);
//name for DataWindow and indicator subwindow label
short_name="Bollinger Percent B (%b)("+BBPeriod_1+","+MainLineMAPeriod_1+") ("+BBPeriod_2+","+MainLineMAPeriod_2+") ("+BBPeriod_3+","+MainLineMAPeriod_3+")";
IndicatorShortName(short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Momentum |
//+------------------------------------------------------------------+
int start() {
if(ShowBand1==TRUE) {
if(Bars<=BBPeriod_1) return(0);
MainFunction(BLG_Buffer_1, MainLineBuffer_1, SignalBuffer_1, Timeframe_1, BBPeriod_1, StdDeviation_1,
AppliedPrice, MainLineMAPeriod_1, MainLineMAMethod_1, SignalMAPeriod_1, SignalMAMethod_1);
}
if(ShowBand2==TRUE) {
if(Bars<=BBPeriod_2) return(0);
MainFunction(BLG_Buffer_2, MainLineBuffer_2, SignalBuffer_2, Timeframe_2, BBPeriod_2, StdDeviation_2,
AppliedPrice, MainLineMAPeriod_2, MainLineMAMethod_2, SignalMAPeriod_2, SignalMAMethod_2);
}
if(ShowBand3==TRUE) {
if(Bars<=BBPeriod_3) return(0);
MainFunction(BLG_Buffer_3, MainLineBuffer_3, SignalBuffer_3, Timeframe_3, BBPeriod_3, StdDeviation_3,
AppliedPrice, MainLineMAPeriod_3, MainLineMAMethod_3, SignalMAPeriod_3, SignalMAMethod_3);
}
return(0);
}
//+------------------------------------------------------------------+
void MainFunction(double &BLGBuffer[], double &MainLineBuffer[], double &SignalBuffer[], int timefame, int BBPeriod, double StdDeviation,
int AppliedPrice, int MainLineMAPeriod, int MainLineMAMethod, int SignalMAPeriod, int SignalMAMethod) {
int i=0,limit=0;
double PriceArray[];
if (ArrayRange(BLGBuffer,0) != Bars) {
ArrayResize(BLGBuffer,Bars);
ArraySetAsSeries(BLGBuffer, TRUE);
}
//number of bars already processed by indicator
int counted_bars=IndicatorCounted();
//load empty values into array until enough elements for calculation
if(counted_bars<1) {
for(i=1;i<=BBPeriod;i++) {
BLGBuffer=EMPTY_VALUE;
}//end for(i=1;i<=BandsPeriod;i++)
}//end if(counted_bars<1)
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars,Bars-BBPeriod);
for(i=limit;i>=0;i--) {
//(Last - Lower BB)/(Upper BB - Lower BB)
BLGBuffer=((Close - iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i))/
(iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_UPPER,i)-iBands(NULL,timefame,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i)))*100;
}//end for(i=limit;i>=0;i--)
//smooth the signal by applying a moving average
for (i = limit; i >= 0; i--) MainLineBuffer = iMAOnArray(BLGBuffer, 0, MainLineMAPeriod, 0, MainLineMAMethod, i);
//create a Signal line (akin to stochastics) by further smoothing the (already smoothed) signal line.
for (i = limit; i >= 0; i--) SignalBuffer = iMAOnArray(MainLineBuffer, 0, SignalMAPeriod, 0, SignalMAMethod, i);
}//end MainFunction()
//--------------------------------------------------------------------------------
//Function: BandCalculation - Not yet working
//Purpose: Calculate the value of either the upper or lower bollinger band depen-
// on input variables.
//Inputs: Mode (int) - Calculate either upper or lower band
// limit (int) - Number of bars to calculate
// timeframe (int)
// BandsPeriod (int)
// MAMethod (int)
// BandsDeviation (double)
// AppliedPrice (int)
//Returns:
//--------------------------------------------------------------------------------
/*
void BandCalculation(int Mode, int limit, int timeframe, int BandsPeriod, int MAMethod, double BandsDeviation, int AppliedPrice) {
int i,k;
double deviation;
double sum,oldval,newres;
//if(counted_bars>0) limit++;
for(i=0; i<limit; i++) {
MovingBuffer=iMA(NULL,0,BandsPeriod,BandsShift,MAMethod,AppliedPrice,i);
}//end for(i=0; i<limit; i++)
i=limit;
//i=Bars-BandsPeriod+1;
//if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
while(i>=0) {
sum=0.0;
k=i+BandsPeriod-1;
oldval=MovingBuffer;
while(k>=i) {
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}//end while(k>=i)
//calculate deviation
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
//Upper/Lower bands are equal to the moving average +/- deviation.
if(Mode==0) {
UpperBuffer=oldval+deviation;
}
else {
LowerBuffer=oldval-deviation;
}
i--;
}//end while(i>=0)
}//end start()
*/