//+------------------------------------------------------------------+ //| PriceSound_FIBOFAN.mq4 | //| Roll | //| Фибовеер со звуком. | //+------------------------------------------------------------------+ #property copyright "Roll" #property link "http://www.mql4.com/ru/users/Roll" #property indicator_chart_window /* Источники: 1)- индикатор PriceAlert(v.1.1)от api(http://codebase.mql4.com/download/17987). Индикатор PriceAlert работает с горизонтальной(ми)линией(ми). "Индикатор автоматически определяет момент пересечения ценой линии и активизирует сигнал"(api). 2)- Индикатор PriceSound_trendline(http://codebase.mql4.com/ru/7601).Работает в тестере. Индикатор PriceSound_trendline работает с трендовой(ми) линией(ми). Для сигнала предпочтение отдается звуку,поэтому звуковой файл должен быть индивидуальным и продолжительностью проигрывания несколько секунд.На графике может находится несколько таких трендовых линий с различными названиями(несколько индикаторов PriceSound_trendline). Замечание: Во время запуска индикаторы PriceSound_...(PriceSound_trendline,PriceSound_channel, PriceSound_Fibochannel,PriceSound_Fibolevels,PriceSound_FIBOFAN)устанавливают или предлагают установить"свои"объекты(по умолчанию), Если пользователь согласен (см.внешние переменные),то"объект"устанавливается немного выше рынка. Далее объект пользователем выделяется и перемещается(D&d),например,для построения линий поддержки/сопротивления и т.п. ================================================================ PriceSound_FIBOFAN работает с объектом "веер Фибоначчи"(OBJ_FIBOFAN),который на фибо-линиях перемещает четыре трендовых линий со свойствами индикатора PriceSound_trendline. PriceSound_FIBOFAN работает в тестере. ================================================================ */ extern bool Sound_Play=true; //разрешение на звук extern string UniqueName1="Fibofan38_1";//название 1 трендовой линии extern color LineColor1=Magenta; //цвет 1 линии extern int LineWidth1=2; //ширина 1 линии extern string Sound1="connect.wav"; //название звукового файла для 1 трендовой линии extern string UniqueName2="Fibofan50_1";//название 2 трендовой линии extern color LineColor2=Gold; //цвет 2 линии extern int LineWidth2=2; //ширина 2 линии extern string Sound2="news.wav"; //название звукового файла для 2 трендовой линии extern string UniqueName3="Fibofan62_1";//название 3 трендовой линии extern color LineColor3=Pink; //цвет 3 линии extern int LineWidth3=2; //ширина 3 линии extern string Sound3="connect.wav"; //название звукового файла для 3 трендовой линии extern string UniqueName4="Fibofan70_1";//название 4 трендовой линии extern color LineColor4=YellowGreen; //цвет 4 линии extern int LineWidth4=2; //ширина 4 линии extern string Sound4="news.wav"; //название звукового файла для 4 трендовой линии extern bool Ind_levels=false; //разрешение/запрет индикации уровней Фибовеера extern int DistPips=0; //Если меньше 10-авт.установка.Регулировка расстояния от изображения числа пунктов до соотв.прямой extern color FIBOFANlevelColor=YellowGreen;//цвет уровней Фибовеера extern bool Create_FIBOFAN=true; //разрешение/запрет на образование OBJ_FIBOFAN (Фибовеера) extern string Name_FIBOFAN="FIBOFAN_1"; //название OBJ_FIBOFAN (Фибовеера) extern bool Del_FIBOFAN=false; //запрет/разрешение на удаление заданного OBJ_FIBOFAN (Фибовеера) int ArrShift;bool Active;string PipsTextName;double LastLevel,LastPrice,TradePoint; static double lastLevel_38,lastLevel_50,lastLevel_62,lastLevel_70,lastPrice_38,lastPrice_50,lastPrice_62,lastPrice_70; int init() {if(Digits==3||Digits==5)TradePoint=Point*10;else TradePoint=Point;LastLevel=0;LastPrice=0; lastLevel_38=0;lastLevel_50=0;lastLevel_62=0;lastLevel_70=0; lastPrice_38=0;lastPrice_50=0;lastPrice_62=0;lastPrice_70=0;Active=true;return(0);} int deinit() {if(UninitializeReason()==REASON_REMOVE){ObjectDelete(Name_FIBOFAN); ObjectDelete(UniqueName1);PipsTextName=UniqueName1+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName2);PipsTextName=UniqueName2+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName3);PipsTextName=UniqueName3+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName4);PipsTextName=UniqueName4+" Pips";ObjectDelete(PipsTextName); lastLevel_38=0;lastLevel_50=0;lastLevel_62=0;lastLevel_70=0; lastPrice_38=0;lastPrice_50=0;lastPrice_62=0;lastPrice_70=0;}return(0);} //+--------Custom indicator iteration function------------------+ int start() {datetime c0,c2,cc0,cc2;double c1,c3,a,b,cp,cp2; switch(Period()) {case PERIOD_M1: if(Period()==PERIOD_M1) {ArrShift=10; break;} case PERIOD_M5: if(Period()==PERIOD_M5) {ArrShift=12; break;} case PERIOD_M15:if(Period()==PERIOD_M15){ArrShift=15; break;} case PERIOD_M30:if(Period()==PERIOD_M30){ArrShift=30; break;} case PERIOD_H1: if(Period()==PERIOD_H1) {ArrShift=50; break;} case PERIOD_H4: if(Period()==PERIOD_H4) {ArrShift=100; break;} case PERIOD_D1: if(Period()==PERIOD_D1) {ArrShift=200; break;} case PERIOD_W1: if(Period()==PERIOD_W1) {ArrShift=500; break;} case PERIOD_MN1:if(Period()==PERIOD_MN1){ArrShift=1000;break;}} if(Del_FIBOFAN) {if(ObjectFind(UniqueName1)==0)PriceSound_trendline(UniqueName1,LineColor1,Sound1,ArrShift,lastLevel_38,lastPrice_38); if(ObjectFind(UniqueName2)==0)PriceSound_trendline(UniqueName2,LineColor2,Sound2,ArrShift,lastLevel_50,lastPrice_50); if(ObjectFind(UniqueName3)==0)PriceSound_trendline(UniqueName3,LineColor3,Sound3,ArrShift,lastLevel_62,lastPrice_62); if(ObjectFind(UniqueName4)==0)PriceSound_trendline(UniqueName4,LineColor4,Sound4,ArrShift,lastLevel_70,lastPrice_70); if(ObjectFind(Name_FIBOFAN)==0)ObjectDelete(Name_FIBOFAN);return(0);} if(ObjectFind(Name_FIBOFAN)!=0&&Create_FIBOFAN) {cp=Close[0]+(10+ArrShift)*TradePoint;cp2=cp+ArrShift*TradePoint; ObjectCreate(Name_FIBOFAN,OBJ_FIBOFAN,0,Time[25],cp,Time[0],cp2);} else if((ObjectFind(Name_FIBOFAN)==0&&!Create_FIBOFAN)||ObjectFind(Name_FIBOFAN)==0) {ObjectSet(Name_FIBOFAN,OBJPROP_COLOR,DarkTurquoise);ObjectSet(Name_FIBOFAN,OBJPROP_STYLE,1); if(Ind_levels) {ObjectSet(Name_FIBOFAN,OBJPROP_FIBOLEVELS,4);ObjectSet(Name_FIBOFAN,OBJPROP_FIRSTLEVEL,0.382); ObjectSet(Name_FIBOFAN,OBJPROP_FIRSTLEVEL+1,0.50);ObjectSet(Name_FIBOFAN,OBJPROP_FIRSTLEVEL+2,0.618); ObjectSet(Name_FIBOFAN,OBJPROP_FIRSTLEVEL+3,0.70);ObjectSetFiboDescription(Name_FIBOFAN,0,"38"); ObjectSetFiboDescription(Name_FIBOFAN,1,"50");ObjectSetFiboDescription(Name_FIBOFAN,2,"62"); ObjectSetFiboDescription(Name_FIBOFAN,3,"70");}else if(!Ind_levels)ObjectSet(Name_FIBOFAN,OBJPROP_FIBOLEVELS,1); ObjectSet(Name_FIBOFAN,OBJPROP_LEVELCOLOR,FIBOFANlevelColor);c0=ObjectGet(Name_FIBOFAN,0); c1=ObjectGet(Name_FIBOFAN,1);c2=ObjectGet(Name_FIBOFAN,2);c3=ObjectGet(Name_FIBOFAN,3);} else if(ObjectFind(Name_FIBOFAN)!=0){Alert("No FIBOFAN - ",Name_FIBOFAN," !");return(0);} a=c3-c1;cc0=c0;cc2=c2; if(ObjectFind(UniqueName1)!=0){b=c3-0.382*a; ObjectCreate(UniqueName1,OBJ_TREND,0,cc0,c1,cc2,b);ObjectSetText(UniqueName1,"Price alert Fibofan 1",0); ObjectSet(UniqueName1,OBJPROP_COLOR,LineColor1);ObjectSet(UniqueName1,OBJPROP_WIDTH,LineWidth1);} if(ObjectFind(UniqueName1)==0){b=c3-0.382*a;ObjectMove(UniqueName1,0,cc0,c1); ObjectMove(UniqueName1,1,cc2,b);ObjectSet(UniqueName1,OBJPROP_WIDTH,LineWidth1); PriceSound_trendline(UniqueName1,LineColor1,Sound1,ArrShift,lastLevel_38,lastPrice_38);} if(ObjectFind(UniqueName2)!=0){b=c3-0.5*a; ObjectCreate(UniqueName2,OBJ_TREND,0,cc0,c1,cc2,b);ObjectSetText(UniqueName2,"Price alert Fibofan 2",0); ObjectSet(UniqueName2,OBJPROP_COLOR,LineColor2);ObjectSet(UniqueName2,OBJPROP_WIDTH,LineWidth2);} if(ObjectFind(UniqueName2)==0){b=c3-0.5*a;ObjectMove(UniqueName2,0,cc0,c1); ObjectMove(UniqueName2,1,cc2,b);ObjectSet(UniqueName2,OBJPROP_WIDTH,LineWidth2); PriceSound_trendline(UniqueName2,LineColor2,Sound2,ArrShift,lastLevel_50,lastPrice_50);} if(ObjectFind(UniqueName3)!=0){b=c3-0.618*a; ObjectCreate(UniqueName3,OBJ_TREND,0,cc0,c1,cc2,b);ObjectSetText(UniqueName3,"Price alert Fibofan 3",0); ObjectSet(UniqueName3,OBJPROP_COLOR,LineColor3);ObjectSet(UniqueName3,OBJPROP_WIDTH,LineWidth3);} if(ObjectFind(UniqueName3)==0){b=c3-0.618*a;ObjectMove(UniqueName3,0,cc0,c1); ObjectMove(UniqueName3,1,cc2,b);ObjectSet(UniqueName3,OBJPROP_WIDTH,LineWidth3); PriceSound_trendline(UniqueName3,LineColor3,Sound3,ArrShift,lastLevel_62,lastPrice_62);} if(ObjectFind(UniqueName4)!=0){b=c3-0.7*a; ObjectCreate(UniqueName4,OBJ_TREND,0,cc0,c1,cc2,b);ObjectSetText(UniqueName4,"Price alert Fibofan 4",0); ObjectSet(UniqueName4,OBJPROP_COLOR,LineColor4);ObjectSet(UniqueName4,OBJPROP_WIDTH,LineWidth4);} if(ObjectFind(UniqueName4)==0){b=c3-0.7*a;ObjectMove(UniqueName4,0,cc0,c1); ObjectMove(UniqueName4,1,cc2,b);ObjectSet(UniqueName4,OBJPROP_WIDTH,LineWidth4); PriceSound_trendline(UniqueName4,LineColor4,Sound4,ArrShift,lastLevel_70,lastPrice_70);}return(0);} //+-------------------------------------------------------------+ void PriceSound_trendline(string UniqueName,color LineColor,string Sound,int arrShift,double lastLevel,double lastPrice) {PipsTextName=StringConcatenate(UniqueName," ","Pips");if(DistPips>=10)ArrShift=DistPips;else ArrShift=arrShift; LastLevel=lastLevel;LastPrice=lastPrice; if(ObjectFind(PipsTextName)==-1){double cp=LastLevel;if(cp==0)cp=LastLevel+(10+ArrShift)*TradePoint; ObjectCreate(PipsTextName,OBJ_TEXT,0,Time[0],cp);} ObjectSet(PipsTextName,OBJPROP_TIME1,Time[0]);double newlevel=ObjectGetValueByShift(UniqueName,0); if(Active){ObjectSet(UniqueName,OBJPROP_COLOR,LineColor);ObjectSetText(UniqueName,"Price sound Fibofan - Active",0); double Pips=MathAbs(NormalizeDouble((newlevel-Close[0])/TradePoint,Digits)); if(Digits==3||Digits==5)ObjectSetText(PipsTextName,DoubleToStr(Pips,1),14,"Terminal",LineColor); else ObjectSetText(PipsTextName,DoubleToStr(Pips,0),14,"Terminal",LineColor);} if(Close[0]>newlevel)ObjectSet(PipsTextName,OBJPROP_PRICE1,newlevel-ArrShift*TradePoint); if(Close[0]=LastLevel)||(LastPrice>LastLevel&&Close[0]<=LastLevel))) {if(Sound_Play)PlaySound(Sound);else Active=false;ObjectSetText(PipsTextName,"",14,"Terminal",LineColor); ObjectSetText(UniqueName,"Price sound Fibofan - Inactive",0);ObjectSet(UniqueName,OBJPROP_COLOR,Blue);} if(UniqueName==UniqueName1){lastLevel_38=LastLevel;lastPrice_38=Close[0];} if(UniqueName==UniqueName2){lastLevel_50=LastLevel;lastPrice_50=Close[0];} if(UniqueName==UniqueName3){lastLevel_62=LastLevel;lastPrice_62=Close[0];} if(UniqueName==UniqueName4){lastLevel_70=LastLevel;lastPrice_70=Close[0];}} //+-------------------------------------------------------------+