//+------------------------------------------------------------------+ //| PriceSound_Fibolevels.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)устанавливают или предлагают установить"свои"объекты(по умолчанию), Если пользователь согласен (см.внешние переменные),то"объект"устанавливается немного выше рынка. Далее объект пользователем выделяется и перемещается(D&d),например,для построения линий поддержки/сопротивления и т.п. ================================================================ PriceSound_Fibolevels работает с объектом "линии Фибоначчи"(OBJ_FIBO),который на фибо-уровнях перемещает восемь трендовых линий со свойствами индикатора PriceSound_trendline, находящихся в горизонтальном положении.PriceSound_Fibolevels работает в тестере. ================================================================*/ extern bool Sound_Play=true; //разрешение на звук extern string UniqueName1="Fibolines0_1"; //название 1 трендовой линии extern color LineColor1=Pink; //цвет 1 линии extern int LineWidth1=2; //ширина 1 линии extern string Sound1="connect.wav"; //название звукового файла для 1 трендовой линии extern string UniqueName2="Fibolines23_1"; //название 2 трендовой линии extern color LineColor2=YellowGreen; //цвет 2 линии extern int LineWidth2=2; //ширина 2 линии extern string Sound2="news.wav"; //название звукового файла для 2 трендовой линии extern string UniqueName3="Fibolines38_1"; //название 3 трендовой линии extern color LineColor3=Pink; //цвет 3 линии extern int LineWidth3=2; //ширина 3 линии extern string Sound3="connect.wav"; //название звукового файла для 3 трендовой линии extern string UniqueName4="Fibolines50_1"; //название 4 трендовой линии extern color LineColor4=YellowGreen; //цвет 4 линии extern int LineWidth4=2; //ширина 4 линии extern string Sound4="news.wav"; //название звукового файла для 4 трендовой линии extern string UniqueName5="Fibolines62_1"; //название 5 трендовой линии extern color LineColor5=Pink; //цвет 5 линии extern int LineWidth5=2; //ширина 5 линии extern string Sound5="connect.wav"; //название звукового файла для 5 трендовой линии extern string UniqueName6="Fibolines_100_1";//название 6 трендовой линии extern color LineColor6=YellowGreen; //цвет 6 линии extern int LineWidth6=2; //ширина 6 линии extern string Sound6="news.wav"; //название звукового файла для 6 трендовой линии extern string UniqueName7="Fiboline_162_1"; //название 7 трендовой линии extern color LineColor7=Pink; //цвет 7 линии extern int LineWidth7=2; //ширина 7 линии extern string Sound7="connect.wav"; //название звукового файла для 7 трендовой линии extern string UniqueName8="Fibolines_262_1";//название 8 трендовой линии extern color LineColor8=YellowGreen; //цвет 8линии extern int LineWidth8=2; //ширина 8 линии extern string Sound8="news.wav"; //название звукового файла для 8 трендовой линии extern color FIBOColor=DarkTurquoise; //цвет Фибо extern color FIBOlevelsColor=DarkTurquoise;//цвет Фибо-уровней extern int LineWidthFIBO=2; //ширина линий Фибо-уровней extern bool Create_FIBO=true; //разрешение/запрет на образование OBJ_FIBO (Фибо-уровней) extern string Name_FIBO="FIBO_1"; //название OBJ_FIBO (Фибо-уровней) extern bool Del_FIBO=false; //запрет/разрешение на удаление заданного OBJ_FIBO (Фибо-уровней) int ArrShift;bool Active;string PipsTextName;double LastLevel,LastPrice,TradePoint; static double lastLevel_0,lastLevel_23,lastLevel_38,lastLevel_50,lastLevel_62,lastLevel_100,lastLevel_162, lastLevel_262,lastPrice_0,lastPrice_23,lastPrice_38,lastPrice_50,lastPrice_62,lastPrice_100,lastPrice_162,lastPrice_262; int init() {if(Digits==3||Digits==5)TradePoint=Point*10;else TradePoint=Point;LastPrice=0; lastLevel_0=0;lastLevel_23=0;lastLevel_38=0;lastLevel_50=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0;lastLevel_262=0; lastPrice_0=0;lastPrice_23=0;lastPrice_38=0;lastPrice_50=0;lastPrice_62=0;lastPrice_100=0;lastPrice_162=0;lastPrice_262=0;Active=true;return(0);} int deinit() {if(UninitializeReason()==REASON_REMOVE){ObjectDelete(Name_FIBO); 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); ObjectDelete(UniqueName5);PipsTextName=UniqueName5+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName6);PipsTextName=UniqueName6+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName7);PipsTextName=UniqueName7+" Pips";ObjectDelete(PipsTextName); ObjectDelete(UniqueName8);PipsTextName=UniqueName8+" Pips";ObjectDelete(PipsTextName); lastLevel_0=0;lastLevel_23=0;lastLevel_38=0;lastLevel_50=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0;lastLevel_262=0; lastPrice_0=0;lastPrice_23=0;lastPrice_38=0;lastPrice_50=0;lastPrice_62=0;lastPrice_100=0;lastPrice_162=0;lastPrice_262=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_FIBO) {if(ObjectFind(UniqueName1)==0)PriceSound_trendline(UniqueName1,LineColor1,Sound1,ArrShift,lastLevel_0,lastPrice_0); if(ObjectFind(UniqueName2)==0)PriceSound_trendline(UniqueName2,LineColor2,Sound2,ArrShift,lastLevel_23,lastPrice_23); if(ObjectFind(UniqueName3)==0)PriceSound_trendline(UniqueName3,LineColor3,Sound3,ArrShift,lastLevel_38,lastPrice_38); if(ObjectFind(UniqueName4)==0)PriceSound_trendline(UniqueName4,LineColor4,Sound4,ArrShift,lastLevel_50,lastPrice_50); if(ObjectFind(UniqueName5)==0)PriceSound_trendline(UniqueName5,LineColor5,Sound5,ArrShift,lastLevel_62,lastPrice_62); if(ObjectFind(UniqueName6)==0)PriceSound_trendline(UniqueName6,LineColor6,Sound6,ArrShift,lastLevel_100,lastPrice_100); if(ObjectFind(UniqueName7)==0)PriceSound_trendline(UniqueName7,LineColor7,Sound7,ArrShift,lastLevel_162,lastPrice_162); if(ObjectFind(UniqueName8)==0)PriceSound_trendline(UniqueName8,LineColor8,Sound8,ArrShift,lastLevel_262,lastPrice_262); if(ObjectFind(Name_FIBO)==0)ObjectDelete(Name_FIBO);return(0);} if(ObjectFind(Name_FIBO)!=0&&Create_FIBO){cp=Close[0]+(10+ArrShift)*TradePoint;cp2=cp+ArrShift*TradePoint; ObjectCreate(Name_FIBO,OBJ_FIBO,0,Time[25],cp,Time[0],cp2);ObjectSet(Name_FIBO,OBJPROP_COLOR,FIBOColor); ObjectSet(Name_FIBO,OBJPROP_LEVELCOLOR,FIBOlevelsColor);ObjectSet(Name_FIBO,OBJPROP_LEVELWIDTH,LineWidthFIBO);} else if((ObjectFind(Name_FIBO)==0&&!Create_FIBO)||ObjectFind(Name_FIBO)==0) {if(ObjectFind(Name_FIBO)==0&&!Create_FIBO) {ObjectSet(Name_FIBO,OBJPROP_COLOR,FIBOColor);ObjectSet(Name_FIBO,OBJPROP_LEVELCOLOR,FIBOlevelsColor); ObjectSet(Name_FIBO,OBJPROP_LEVELWIDTH,LineWidthFIBO);} c0=ObjectGet(Name_FIBO,0);c1=ObjectGet(Name_FIBO,1);c2=ObjectGet(Name_FIBO,2);c3=ObjectGet(Name_FIBO,3);} else if(ObjectFind(Name_FIBO)!=0){Alert("No Fibo - ",Name_FIBO," !");return(0);} a=c3-c1;if(c2>c0){cc0=c0;cc2=c2;}else if(c2newlevel)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 level - Inactive",0);ObjectSet(UniqueName,OBJPROP_COLOR,Blue);} if(UniqueName==UniqueName1){lastLevel_0=LastLevel;lastPrice_0=Close[0];} if(UniqueName==UniqueName2){lastLevel_23=LastLevel;lastPrice_23=Close[0];} if(UniqueName==UniqueName3){lastLevel_38=LastLevel;lastPrice_38=Close[0];} if(UniqueName==UniqueName4){lastLevel_50=LastLevel;lastPrice_50=Close[0];} if(UniqueName==UniqueName5){lastLevel_62=LastLevel;lastPrice_62=Close[0];} if(UniqueName==UniqueName6){lastLevel_100=LastLevel;lastPrice_100=Close[0];} if(UniqueName==UniqueName7){lastLevel_162=LastLevel;lastPrice_162=Close[0];} if(UniqueName==UniqueName8){lastLevel_262=LastLevel;lastPrice_262=Close[0];}} //+-------------------------------------------------------------+