//+------------------------------------------------------------------+ //| Forecast Oscillator.mq4 | //| Copyright © 2005, Nick Bilak, beluck[AT]gmail.com | //| http://forexsystems.ru/phpBB/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Nick Bilak, beluck[AT]gmail.com" #property link "http://forexsystems.ru/phpBB/index.php" #define indicatorName "All Oscillator" #property indicator_separate_window #property indicator_buffers 6 #property indicator_level1 0 #property indicator_color1 DarkTurquoise #property indicator_color2 LawnGreen #property indicator_color3 Magenta #property indicator_color4 Aqua //---- input parameters extern string __ = "Chose timeframes (as in periodicity bar)"; extern string timeFrames = "M1;M5;M15;M30;H1;H4;D1;W1;MN"; extern int barsPerTimeFrame = 35; extern bool shiftRight = False; extern color txtColor = Silver; extern color separatorColor = DimGray; extern int regress=15; extern int t3=10; extern double b=0.7; //---- buffers double osc[]; double osct3[]; double hiSig[]; double loSig[]; int shift,limit,length; double b2,b3,c1,c2,c3,c4,w1,w2,n,WT,forecastosc,t3_fosc,sum,e1,e2,e3,e4,e5,e6,tmp,tmp2; //---- buffers // // // // // double ExtMapBuffer1[]; double ExtMapBuffer2[]; // // // // // string shortName; string labels[]; int periods[]; int Shift; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators if (shiftRight) Shift = 1; else Shift = 0; SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(0,osc); SetIndexEmptyValue(0,0); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexShift(0,Shift*(barsPerTimeFrame+1)); SetIndexShift(1,Shift*(barsPerTimeFrame+1)); SetIndexBuffer(1,osct3); SetIndexStyle(2,DRAW_ARROW); SetIndexBuffer(2,hiSig); SetIndexEmptyValue(2,EMPTY_VALUE); SetIndexArrow(2,159); SetIndexStyle(3,DRAW_ARROW); SetIndexBuffer(3,loSig); SetIndexEmptyValue(3,EMPTY_VALUE); SetIndexArrow(3,159); // // // // // barsPerTimeFrame = MathMax(barsPerTimeFrame,30); SetIndexLabel(0,"oscillator"); SetIndexLabel(1,"Signal"); shortName = indicatorName+" ("+regress+","+t3+","+b+")"; IndicatorShortName(shortName); // // // // // timeFrames = StringUpperCase(StringTrimLeft(StringTrimRight(timeFrames))); if (StringSubstr(timeFrames,StringLen(timeFrames),1) != ";") timeFrames = StringConcatenate(timeFrames,";"); // // // // // int s = 0; int i = StringFind(timeFrames,";",s); int time; string current; while (i > 0) { current = StringSubstr(timeFrames,s,i-s); time = stringToTimeFrame(current); if (time > 0) { ArrayResize(labels ,ArraySize(labels)+1); ArrayResize(periods,ArraySize(periods)+1); labels[ArraySize(labels)-1] = current; periods[ArraySize(periods)-1] = time; } s = i + 1; i = StringFind(timeFrames,";",s); } // // // // // for (i=1;i<ArraySize(periods);i++) if (Period()==periods[i]) { string tmpLbl = labels[i]; int tmpPer = periods[i]; // // // // // for (int k=i ;k>0; k--) { labels[k] = labels[k-1]; periods[k] = periods[k-1]; } labels[0] = tmpLbl; periods[0] = tmpPer; } return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { for(int l=0;l<ArraySize(periods);l++) { ObjectDelete(indicatorName+l); ObjectDelete(indicatorName+l+1); } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { string on; int wn=WindowFind(shortName); int k=0; // // // // // for(int p=0; p<ArraySize(periods);p++) { for(int i=0; i<barsPerTimeFrame;i++,k++) { ExtMapBuffer1[k] = iCustom(NULL,periods[p],"ForecastOscillator",regress,t3,b,0,i); ExtMapBuffer2[k] = iCustom(NULL,periods[p],"ForecastOscillator",regress,t3,b,1,i); } k += 1; ExtMapBuffer1[k] =EMPTY_VALUE; ExtMapBuffer2[k] =EMPTY_VALUE; // // // // // on = indicatorName+p; if(ObjectFind(on)==-1) ObjectCreate(on,OBJ_TREND,wn,0,0); ObjectSet(on,OBJPROP_TIME1,myTime(k-Shift*(barsPerTimeFrame+1)-1)); ObjectSet(on,OBJPROP_TIME2,myTime(k-Shift*(barsPerTimeFrame+1)-1)); ObjectSet(on,OBJPROP_PRICE1, 0); ObjectSet(on,OBJPROP_PRICE2,100); ObjectSet(on,OBJPROP_COLOR ,separatorColor); ObjectSet(on,OBJPROP_WIDTH ,2); on = indicatorName+p+1; if(ObjectFind(on)==-1) ObjectCreate(on,OBJ_TEXT,wn,0,0); ObjectSet(on,OBJPROP_TIME1,myTime(k-Shift*(barsPerTimeFrame+1)-6)); ObjectSet(on,OBJPROP_PRICE1,100); ObjectSetText(on,labels[p],9,"Arial",txtColor); } // // // // // SetIndexDrawBegin(0,Bars-k); SetIndexDrawBegin(1,Bars-k); return(0); } //+------------------------------------------------------------------+ //+ Custom functions and procedures + //+------------------------------------------------------------------+ int myTime(int a) { if(a<0) return(Time[0]+Period()*60*MathAbs(a)); else return(Time[a]); } //+------------------------------------------------------------------+ //+ + //+------------------------------------------------------------------+ // // // // // int stringToTimeFrame(string TimeFrame) { int TimeFrameInt=0; if (TimeFrame=="M1") TimeFrameInt=1; if (TimeFrame=="M5") TimeFrameInt=5; if (TimeFrame=="M15") TimeFrameInt=15; if (TimeFrame=="M30") TimeFrameInt=30; if (TimeFrame=="H1") TimeFrameInt=60; if (TimeFrame=="H4") TimeFrameInt=240; if (TimeFrame=="D1") TimeFrameInt=1440; if (TimeFrame=="W1") TimeFrameInt=10080; if (TimeFrame=="MN") TimeFrameInt=43200; return(TimeFrameInt); } // // // // // string StringUpperCase(string str) { string s = str; int lenght = StringLen(str) - 1; int char; while(lenght >= 0) { char = StringGetChar(s, lenght); // // // // // if((char > 96 && char < 123) || (char > 223 && char < 256)) s = StringSetChar(s, lenght, char - 32); else if(char > -33 && char < 0) s = StringSetChar(s, lenght, char + 224); // // // // // lenght--; } // // // // // return(s); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Indicators Used:
Custom Indicators Used:
ForecastOscillator
Order Management characteristics:
Other Features: