//+------------------------------------------------------------------+ //| SpudsStochastic.mq4 | //| Copyright © 2012, Vladimir Hlystov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2012, Vladimir Hlystov" #property link "cmillion@narod.ru" //+------------------------------------------------------------------+ extern bool AlertON = false; extern bool DrawARROW = true; extern int LevelUp = 85; extern int LevelDn = 15; //+------------------------------------------------------------------+ /*8 стохастических осцилляторов. Параметры «замедление» и «период %D» оставляем по умолчанию – 3. Параметр %K будет меняться от 6 до 24. Таким образом, мы имеем 8 стохастиков с параметрами (6, 3, 3), (7, 3, 3), (8, 3, 3) … (24, 3, 3). У всех индикаторов используется только главная линия, а сигнальную мы отключаем. */ //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_level1 15 #property indicator_level2 85 #property indicator_levelcolor Silver #property indicator_levelwidth 0 #property indicator_levelstyle 2 #property indicator_buffers 8 #property indicator_color1 Blue #property indicator_style1 2 #property indicator_width1 1 #property indicator_color2 Blue #property indicator_style2 2 #property indicator_width2 1 #property indicator_color3 Blue #property indicator_style3 2 #property indicator_width3 1 #property indicator_color4 Yellow #property indicator_style4 2 #property indicator_width4 2 #property indicator_color5 Red #property indicator_style5 2 #property indicator_width5 1 #property indicator_color6 Red #property indicator_style6 2 #property indicator_width6 1 #property indicator_color7 Red #property indicator_style7 2 #property indicator_width7 1 #property indicator_color8 Red #property indicator_style8 2 #property indicator_width8 1 //---- buffers double BUFFER_1[]; double BUFFER_2[]; double BUFFER_3[]; double BUFFER_4[]; double BUFFER_5[]; double BUFFER_6[]; double BUFFER_7[]; double BUFFER_8[]; int Signal; //+------------------------------------------------------------------+ int init() { //---- indicator lines SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,BUFFER_1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,BUFFER_2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,BUFFER_3); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,BUFFER_4); SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(4,BUFFER_5); SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,BUFFER_6); SetIndexStyle(6,DRAW_LINE); SetIndexBuffer(6,BUFFER_7); SetIndexStyle(7,DRAW_LINE); SetIndexBuffer(7,BUFFER_8); //---- name for DataWindow and indicator subwindow label SetIndexLabel(0,"(6, 3, 3)"); SetIndexLabel(1,"(9, 3, 3)"); SetIndexLabel(2,"(12, 3, 3)"); SetIndexLabel(3,"(14, 3, 3)"); SetIndexLabel(4,"(16, 3, 3)"); SetIndexLabel(5,"(19, 3, 3)"); SetIndexLabel(6,"(21, 3, 3)"); SetIndexLabel(7,"(24, 3, 3)"); string Name="Spuds Stochastic"; IndicatorShortName(Name); ObjectCreate("SpudsStochastic_on",OBJ_LABEL,WindowFind(Name),0,0);// Создание объ. ObjectSet("SpudsStochastic_on",OBJPROP_CORNER,0); ObjectSet("SpudsStochastic_on",OBJPROP_XDISTANCE,5); ObjectSet("SpudsStochastic_on",OBJPROP_YDISTANCE,15); if(AlertON)ObjectSetText("SpudsStochastic_on","Alert ON",8,"Arial",Blue); else ObjectSetText("SpudsStochastic_on","Alert OFF",8,"Arial",Red); return(0); } //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; if(counted_bars==0) limit-=1+1; string name; for(int i=limit; i>=0; i--) { BUFFER_1[i] = iStochastic(NULL,0,6,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_2[i] = iStochastic(NULL,0,9,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_3[i] = iStochastic(NULL,0,12,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_4[i] = iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_5[i] = iStochastic(NULL,0,16,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_6[i] = iStochastic(NULL,0,19,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_7[i] = iStochastic(NULL,0,21,3,3,MODE_SMA,0,MODE_MAIN,i); BUFFER_8[i] = iStochastic(NULL,0,24,3,3,MODE_SMA,0,MODE_MAIN,i); if((BUFFER_1[i+1]>LevelUp && BUFFER_2[i+1]>LevelUp && BUFFER_3[i+1]>LevelUp && BUFFER_4[i+1]>LevelUp && BUFFER_5[i+1]>LevelUp && BUFFER_6[i+1]>LevelUp && BUFFER_7[i+1]>LevelUp && BUFFER_8[i+1]>LevelUp) || (BUFFER_1[i+1]LevelDn && BUFFER_2[i]>LevelDn && BUFFER_3[i]>LevelDn && BUFFER_4[i]>LevelDn && BUFFER_5[i]>LevelDn && BUFFER_6[i]>LevelDn && BUFFER_7[i]>LevelDn && BUFFER_8[i]>LevelDn) && (BUFFER_1[i+1]LevelUp || BUFFER_2[i+1]>LevelUp || BUFFER_3[i+1]>LevelUp || BUFFER_4[i+1]>LevelUp || BUFFER_5[i+1]>LevelUp || BUFFER_6[i+1]>LevelUp || BUFFER_7[i+1]>LevelUp || BUFFER_8[i+1]>LevelUp)) { if(DrawARROW && Signal==0) { name=StringConcatenate("SpudsStochastic_",TimeToStr(Time[i],TIME_DATE|TIME_MINUTES)); ObjectDelete(name); ObjectCreate(name,OBJ_ARROW,0,Time[i],High[i],0,0,0,0); ObjectSet(name,OBJPROP_ARROWCODE,238); ObjectSet(name,OBJPROP_COLOR,Red); Signal=-1; } if(AlertON && i<2) Alert(Symbol()+" Spuds Stochastic Sell"); } } return(0); } //+------------------------------------------------------------------+ int deinit() { remove_objects("SpudsStochastic_"); } //+------------------------------------------------------------------+ int remove_objects(string PreName) { for(int k=ObjectsTotal()-1; k>=0; k--) { string Obj_Name=ObjectName(k); string Head=StringSubstr(Obj_Name,0,StringLen(PreName)); if(Head==PreName) { ObjectDelete(Obj_Name); } } return(0); } //--------------------------------------------------------------------+