//+------------------------------------------------------------------+ //| iTrend.mq4 | //| Copyright © 2004, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //mod2009fxtsd ki #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 DarkKhaki #property indicator_color2 Red #property indicator_color3 BlueViolet #property indicator_color4 SlateBlue //---- input parameters extern int Bands_Mode=0; // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH extern int Bands_Price=0; // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED extern int Bands_Period=20; extern int Bands_Deviation=2; extern int Power_Period=13; extern int Power_Price=0; // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW extern bool StDevBandsOn = true; extern double StDeviation = 1.23; extern int StDevPeriod=13; extern int CountBars=900; extern string note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6"; extern string Bands_mode_ = "0-2 MODE_MAIN0, MODE_LOW1, MODE_HIGH2"; //---- buffers double value[]; double value2[]; double stdh[]; double stdl[]; double val[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { // string short_name; //---- indicator line IndicatorBuffers(5); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(0,value); SetIndexBuffer(1,value2); SetIndexDrawBegin(0,Bars-CountBars+Bands_Period+1); SetIndexDrawBegin(1,Bars-CountBars+Bands_Period+1); if (StDevBandsOn) { SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(2,stdh); SetIndexBuffer(3,stdl); SetIndexBuffer(4,val); SetIndexDrawBegin(2,Bars-CountBars+Bands_Period+1); SetIndexDrawBegin(3,Bars-CountBars+Bands_Period+1); } //---- //---- return(0); } //+------------------------------------------------------------------+ //| Trend | //+------------------------------------------------------------------+ int start() { int i,CurrentBar,Bands_Mode,counted_bars=IndicatorCounted(); double Power_Price,CurrentPrice; //---- if(Bars<=Bands_Period) return(0); //---- initial zero if(counted_bars=0; i--) { CurrentPrice=iMA(NULL,0,1,0,0,Power_Price,i) ; value [i]=CurrentPrice-iBands(NULL,0,Bands_Period,Bands_Deviation,0,Bands_Mode,Bands_Price,i); value2 [i]=-(iBearsPower(NULL,0,Power_Period,Power_Price,i)+iBullsPower(NULL,0,Power_Period,Power_Price,i)); val [i]=value[i]+value2[i]; } if (StDevBandsOn) for (i=CountBars-StDevPeriod-1; i>=0; i--) { double std = StDeviation*iStdDevOnArray(val,0,StDevPeriod,0,0,i); stdh[i]= +std; stdl[i]= -std; } return(0); } //+------------------------------------------------------------------+