//+------------------------------------------------------------------+ //| SignalTable.mq5 | //| Copyright © 2007, Antonuk Oleg | //| antonukoleg@gmail.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, Antonuk Oleg" #property link "antonukoleg@gmail.com" #property version "1.00" #property description "Buy and sell signals à several indicators and different timeframes in a table" //---- The indicator version #property version "1.00" //---- The indicator drawn in the main window #property indicator_chart_window //---- No buffers used for the calculation and drawing of the indicator #property indicator_buffers 0 //---- 0 graphical constructions used #property indicator_plots 0 //+----------------------------------------------+ //| Declaration of constants | //+----------------------------------------------+ #define RESET 0 // A constant for returning indicator recalculation commands to the terminal //+----------------------------------------------+ // Description of the type_font enumeration | // Description of the CFontName class | //+----------------------------------------------+ #include //+----------------------------------------------+ //| Input parameters of the indicator | //+----------------------------------------------+ input string Symbol_=""; // Financial symbol input color TextColor=clrGray; // Text color input color UpColor=clrTeal; // The color of an upward trend input color MdColor=clrGray; // The color of no trend input color DnColor=clrMagenta; // The color of a downward trend input int FontSize=13; // Font size input type_font FontType=Font14; // Font type input ENUM_BASE_CORNER WhatCorner=CORNER_LEFT_LOWER; // The corner to position input uint Y_=20; // Vertical positioning input uint X_=5; // Horizontal positioning input string LableSirname="SignalTable 1"; //+----------------------------------------------+ //---- Declaring integer variables of data calculation start int min_rates_total; double Width; ENUM_ANCHOR_POINT SPoint; string sFontType,Lable1,Lable2,Lable3,Lable4,Lable1_[9],Lable2_[9],Lable3_[9],Lable4_[9],symbol; uint shift_1,shift_2,shift_3,shift_4,X1,X2,X2i[9]; ENUM_TIMEFRAMES period[]={PERIOD_M1,PERIOD_M5,PERIOD_M15,PERIOD_M30,PERIOD_H1,PERIOD_H4,PERIOD_D1,PERIOD_W1,PERIOD_MN1}; //---- Create one more array with the indicator names string signalNameString[]={"MA","WPR","SAR"}; //---- Declaring integer variables or the indicator handles int FsMA_Handle[9],SlMA_Handle[9],WPR_Handle[9],SAR_Handle[9]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- Initialization of variables of the start of data calculation min_rates_total=1; //---- initialization of variables if(Symbol_!="") symbol=Symbol_; else symbol=Symbol(); Width=3.3; //Width between the symbols SPoint=ENUM_ANCHOR_POINT(2*WhatCorner); //---- Getting handles for(int iii=0; iii<9; iii++) { //---- Getting the handle of the iMA indicator FsMA_Handle[iii]=iMA(symbol,period[iii],13,0,MODE_SMA,PRICE_CLOSE); if(FsMA_Handle[iii]==INVALID_HANDLE) Print(" Failed to get the handle of iMA"); //---- Getting the handle of the iMA indicator SlMA_Handle[iii]=iMA(symbol,period[iii],24,0,MODE_SMA,PRICE_CLOSE); if(SlMA_Handle[iii]==INVALID_HANDLE) Print(" Failed to get the handle of iMA"); //---- getting handle of the iWPR indicator WPR_Handle[iii]=iWPR(symbol,period[iii],13); if(WPR_Handle[iii]==INVALID_HANDLE) Print(" Failed to get the handle of iWPR"); //---- getting handle of the iSAR indicator SAR_Handle[iii]=iSAR(symbol,period[iii],0.02,0.2); if(SAR_Handle[iii]==INVALID_HANDLE) Print(" Failed to get the handle of iSAR"); } //---- CFontName FONT; sFontType=FONT.GetFontName(FontType); Deinit(); //---- Lable1=LableSirname+"_"+"String_0"; Lable2=LableSirname+"_"+"String_1"; Lable3=LableSirname+"_"+"String_2"; Lable4=LableSirname+"_"+"String_3"; for(int iii=0; iii<9; iii++) { Lable1_[iii]=LableSirname+"_"+"String_0_"+string(iii); Lable2_[iii]=LableSirname+"_"+"String_1_"+string(iii); Lable3_[iii]=LableSirname+"_"+"String_2_"+string(iii); Lable4_[iii]=LableSirname+"_"+"String_3_"+string(iii); } //---- switch(WhatCorner) { case CORNER_RIGHT_LOWER: { shift_1=int(Y_+FontSize*6); shift_2=int(Y_+FontSize*4); shift_3=int(Y_+FontSize*2); shift_4=int(Y_+0); X1=int(X_+FontSize*3); X2=int(X_); break; } case CORNER_LEFT_LOWER: { shift_1=int(Y_+FontSize*6); shift_2=int(Y_+FontSize*4); shift_3=int(Y_+FontSize*2); shift_4=int(Y_+0); X1=int(X_); X2=X_+FontSize*5; break; } case CORNER_RIGHT_UPPER: { shift_1=int(Y_+0); shift_2=int(Y_+FontSize*2); shift_3=int(Y_+FontSize*4); shift_4=int(Y_+FontSize*6); X1=int(X_+FontSize*3); X2=int(X_); break; } case CORNER_LEFT_UPPER: { shift_1=int(Y_+0); shift_2=int(Y_+FontSize*2); shift_3=int(Y_+FontSize*4); shift_4=int(Y_+FontSize*6); X1=int(X_); X2=int(X_+FontSize*5); } } SetTLabel(0,Lable1,0,WhatCorner,SPoint,X1,shift_1,"Sar: ",TextColor,sFontType,FontSize); SetTLabel(0,Lable2,0,WhatCorner,SPoint,X1,shift_2,"WPR: ",TextColor,sFontType,FontSize); SetTLabel(0,Lable3,0,WhatCorner,SPoint,X1,shift_3,"MA: ",TextColor,sFontType,FontSize); for(int iii=0; iii<9; iii++) X2i[iii]=X2+int(Width*iii*FontSize); for(int iii=0; iii<9; iii++) SetTLabel(0,Lable4_[iii],0,WhatCorner,SPoint,X2i[iii],shift_4,GetStringTimeframe(period[iii]),TextColor,sFontType,FontSize); //---- End of initialization } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //---- Deinit(); //---- ChartRedraw(0); } //+------------------------------------------------------------------+ //| Variable arrays fro creating indicator values | //+------------------------------------------------------------------+ class CArray { public: double IndArr[]; }; //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate( const int rates_total, // amount of history in bars at the current tick const int prev_calculated,// amount of history in bars at the previous tick const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) { //---- Check if the number of bars is enough for the calculation for(int iii=0; iii<9; iii++) if(BarsCalculated(FsMA_Handle[iii])close[rates_total-1]) { Symb="ä"; Color=DnColor; } else { Symb="a"; Color=MdColor; } SetTLabel(0,Lable1_[iii],0,WhatCorner,SPoint,X2i[iii],shift_1,Symb,Color,"Wingdings 3",FontSize); } //---- for(int iii=0; iii<9; iii++) { if(WPR[iii].IndArr[0]<20) { Symb="ã"; Color=UpColor; } else if(WPR[iii].IndArr[0]>80) { Symb="ä"; Color=DnColor; } else { Symb="a"; Color=MdColor; } SetTLabel(0,Lable2_[iii],0,WhatCorner,SPoint,X2i[iii],shift_2,Symb,Color,"Wingdings 3",FontSize); } //---- for(int iii=0; iii<9; iii++) { if(FsMA[iii].IndArr[0]>SlMA[iii].IndArr[0]) { Symb="ã"; Color=UpColor; } else if(FsMA[iii].IndArr[0]