//===================================================================================================================== // (c) 2011 Sealdo - sealdo@yandex.ru //===================================================================================================================== #property copyright "Sealdo" #property indicator_separate_window //#property indicator_minimum 0 //#property indicator_maximum 100 //#property indicator_level1 20 //#property indicator_level2 80 #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Yellow #property indicator_color3 LightSalmon #property indicator_color4 Blue #property indicator_color5 Magenta #property indicator_color6 Aqua #property indicator_color7 Green #property indicator_color8 Indigo extern int Smyth = 1; extern int Fast_MA = 1; extern int Slow_MA = 3000; extern int FastMA_Appl_price = 0; /* 0 Close price. 1 Open price. 2 High price. 3 Low price. 4 Median price, (high+low)/2. 5 Typical price, (high+low+close)/3. 6 Weighted close price, (high+low+close+close)/4. */ extern int bars = 10000; //extern int d_period = 8; //extern int slowing = 5; //extern int method = 3; extern string Sym1 = "GAZP"; extern string Sym2 = "CHMF"; extern string Sym3 = "HYDR"; extern string Sym4 = "MTS"; extern string Sym5 = "ROSN"; extern string Sym6 = "RTKMP"; extern string Sym7 = "SBER"; extern string Sym8 = "URKA"; extern double K1 = 2; extern double K2 = 1; extern double K3 = 400; extern double K4 = 3; extern double K5 = 2; extern double K6 = 8; extern double K7 = 5; extern double K8 = 2; //---- buffers double Buf1[]; double Buf2[]; double Buf3[]; double Buf4[]; double Buf5[]; double Buf6[]; double Buf7[]; double Buf8[]; string aSymbol[9]; double aK[9]; //===================================================================================================================== int init() { IndicatorShortName("_i_Stocks_OSMA (" + Smyth + "," + Fast_MA + "," + Slow_MA + ")"); SetIndexBuffer(0, Buf1); SetIndexBuffer(1, Buf2); SetIndexBuffer(2, Buf3); SetIndexBuffer(3, Buf4); SetIndexBuffer(4, Buf5); SetIndexBuffer(5, Buf6); SetIndexBuffer(6, Buf7); SetIndexBuffer(7, Buf8); aSymbol[1] = Sym1; aK[1] = K1; SetIndexLabel(0, Sym1); aSymbol[2] = Sym2; aK[2] = K2; SetIndexLabel(1, Sym2); aSymbol[3] = Sym3; aK[3] = K3; SetIndexLabel(2, Sym3); aSymbol[4] = Sym4; aK[4] = K4; SetIndexLabel(3, Sym4); aSymbol[5] = Sym5; aK[5] = K5; SetIndexLabel(4, Sym5); aSymbol[6] = Sym6; aK[6] = K6; SetIndexLabel(5, Sym6); aSymbol[7] = Sym7; aK[7] = K7; SetIndexLabel(6, Sym7); aSymbol[8] = Sym8; aK[8] = K8; SetIndexLabel(7, Sym8); for (int i=0; i<=7; i++) { int w = 0; if (aSymbol[i+1] == Symbol()) w = 3; if (aSymbol[i+1] == "") aK[i+1] = 0; SetIndexStyle(i, DRAW_LINE, STYLE_SOLID, w); } return(0); } //===================================================================================================================== int deinit() { for (int s = 1; s <= 8; s++) { ObjectDelete(aSymbol[s]); } } //===================================================================================================================== //===================================================================================================================== int start() { static int b; static int s, time, time2; static int prev_Bars, pos2, p, bars2; static double v, Buf[]; int counted_bars = IndicatorCounted(); if(counted_bars>0) counted_bars--; int limit = Bars - counted_bars; if ((bars < 1) || bars > Bars) bars = Bars; limit = bars; ArrayResize(Buf, bars + Slow_MA); ArraySetAsSeries(Buf, true); for (s = 1; s<=8; s++) { if (aK[s] != 0.0) { ArrayInitialize(Buf, 0); pos2 = 0; bars2 = iBars(aSymbol[s], 0); for(b=0; b= 0; b--) { v = iMAOnArray(Buf, 0, Smyth, 0, 3, b); switch (s) { case 1: Buf1[b] = v; break; case 2: Buf2[b] = v; break; case 3: Buf3[b] = v; break; case 4: Buf4[b] = v; break; case 5: Buf5[b] = v; break; case 6: Buf6[b] = v; break; case 7: Buf7[b] = v; break; case 8: Buf8[b] = v; break; } } } } // названия символов static string space = " "; ShowTextObject(aSymbol[1], space + aSymbol[1], 0, Buf1[0], Red); ShowTextObject(aSymbol[2], space + aSymbol[2], 0, Buf2[0], Yellow); ShowTextObject(aSymbol[3], space + aSymbol[3], 0, Buf3[0], LightSalmon); ShowTextObject(aSymbol[4], space + aSymbol[4], 0, Buf4[0], Blue); ShowTextObject(aSymbol[5], space + aSymbol[5], 0, Buf5[0], Magenta); ShowTextObject(aSymbol[6], space + aSymbol[6], 0, Buf6[0], Aqua); ShowTextObject(aSymbol[7], space + aSymbol[7], 0, Buf7[0], Green); ShowTextObject(aSymbol[8], space + aSymbol[8], 0, Buf8[0], Indigo); return(0); } //===================================================================================================================== void ShowTextObject(string pName, string pText, int pBar, double pPrice, color pColor) { ObjectDelete(pName); ObjectCreate(pName, OBJ_TEXT, 1, Time[pBar], pPrice); ObjectSet(pName, OBJPROP_COLOR, pColor); ObjectSetText(pName, pText, 10, "arial"); }