Attached File(s)
PAIN.mq4
1 KB
|
303 downloads
THis indicator basically takes the average of for calculation depending on the time period.
I want to just take values of Open,Close, High, Low within the period, and do the calculation that way. Instead of taking average for each bar for that time period
Ex:
past 20 days:
Close = 20th day close
Open = 1st day open
High = Highest high within 20 days
Low = Lowest low within 20 days
and do the calculation that way instead of the average for each day. Anyone could lend me some help?
-----------------------------------------------------------------------------------------------------------
// See http://www.forexrealm.com/technical-...indicator.html
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime
extern int MoveAvgPeriod = 1;
extern int MoveAvgMethod = MODE_SMA;
double dPainBuffer[];
int init() {
IndicatorShortName("PAIN");
SetIndexBuffer(0,dPainBuffer);
SetIndexLabel(0,"PAIN");
return(0);
}
int start() {
int iBarsToCalc = Bars - IndicatorCounted();
if (iBarsToCalc < Bars) iBarsToCalc++;
for (int i=iBarsToCalc-1;i>=0;i--) {
double dCloseMA = iMA(NULL,0,MoveAvgPeriod,0,MoveAvgMethod,PRICE_CLOSE,i);
double dOpenMA = iMA(NULL,0,MoveAvgPeriod,0,MoveAvgMethod,PRICE_OPEN, i);
double dHigheMA = iMA(NULL,0,MoveAvgPeriod,0,MoveAvgMethod,PRICE_HIGH, i);
double dLowMA = iMA(NULL,0,MoveAvgPeriod,0,MoveAvgMethod,PRICE_LOW, i);
dPainBuffer[i] = ( (dCloseMA-dOpenMA)+(dCloseMA-dHigheMA)+(dCloseMA-dLowMA) );
}
return(0);
}
---------------------------------------------------------------------------------------------------
Working towards CME membership