//+------------------------------------------------------------------+ //| PriceSound_Fibochannel.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 от Roll.http://codebase.mql4.com/ru/7601. Индикатор PriceSound_trendline работает с трендовой(ми) линией(ми).Работает в тестере. Для сигнала предпочтение отдается звуку,поэтому звуковой файл должен быть индивидуальным и продолжительностью проигрывания 4-6 сек). На графике может находится несколько таких трендовых линий с различными названиями (несколько индикаторов PriceSound_trendline). 3)- Индикатор PriceSound_channel от Roll. http://codebase.mql4.com/ru/7609 Индикатор PriceSound_channel работает с "каналами",которые сопровождают трендовые линии. Работает в тестере. В индикаторе используется функция,выполненная из индикатора PriceSound_trendline. То есть индикатор PriceSound_channel имеет свойства,характерные для индикатора PriceSound_trendline. ======================================================================= Замечание:Во время запуска индикаторы PriceSound_...(PriceSound_trendline,PriceSound_channel, PriceSound_Fibochannel)устанавливают или предлагают установить"свои"объекты(по умолчанию), если пользователь согласен (см.внешние переменные),то "объект"устанавливается немного выше рынка.Далее пользователь выделяет объект и перетаскивает в нужное ему место (D&d),например,для построения линий поддержки/сопротивления и т.п. ======================================================================== - Индикатор PriceSound_Fibochannel работает с "Фибо-каналами",которые перемещают трендовые линии со свойствами индикатора PriceSound_trendline.Работает в тестере. ======================================================================== */ extern bool Sound_Play=true; //разрешение на звук extern string UniqueName1="FiboTrend_mainPrice 1";//название 1 трендовой линии extern color LineColor1=Pink; //цвет 1 линии extern int LineWidth1=2; //ширина 1 линии extern string Sound1="ready.wav"; //название звукового файла для 1 трендовой линии extern string UniqueName2="FiboTrend__0%Price 1";//название 2 трендовой линии extern color LineColor2=YellowGreen; //цвет 2 линии extern int LineWidth2=2; //ширина 2 линии extern string Sound2="ready.wav"; //название звукового файла для 2 трендовой линии extern string UniqueName3="FiboTrend_62%Price 1";//название 3 трендовой линии extern color LineColor3=Pink; //цвет 3 линии extern int LineWidth3=2; //ширина 3 линии extern string Sound3="ready.wav"; //название звукового файла для 3 трендовой линии extern string UniqueName4="FiboTrend_100%Price 1";//название 4 трендовой линии extern color LineColor4=YellowGreen; //цвет 4 линии extern int LineWidth4=2; //ширина 4 линии extern string Sound4="ready.wav"; //название звукового файла для 4 трендовой линии extern string UniqueName5="FiboTrend_162%Price 1";//название 5 трендовой линии extern color LineColor5=Pink; //цвет 5 линии extern int LineWidth5=2; //ширина 5 линии extern string Sound5="ready.wav"; //название звукового файла для 5 трендовой линии extern string UniqueName6="FiboTrend_262%Price 1";//название 6 трендовой линии extern color LineColor6=YellowGreen; //цвет 6 линии extern int LineWidth6=2; //ширина 6 линии extern string Sound6="ready.wav"; //название звукового файла для 6 трендовой линии extern color FChannelColor=DarkTurquoise;//цвет канала extern bool Create_FChannel=true; //разрешение/запрет на образование канала extern string Name_FChannel="FChannel_1"; //название канала extern bool Del_FChannel=false; //запрет/разрешение на удаление заданного канала int ArrShift;bool Active;string PipsTextName;double LastLevel,LastPrice,TradePoint; static double lastLevel_1,lastLevel_2,lastLevel_62,lastLevel_100,lastLevel_162,lastLevel_262, lastPrice_1,lastPrice_2,lastPrice_62,lastPrice_100,lastPrice_162,lastPrice_262; int init() {if(Digits==3||Digits==5)TradePoint=Point*10;else TradePoint=Point; LastPrice=0;lastLevel_1=0;lastLevel_2=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0; lastLevel_262=0;lastPrice_1=0;lastPrice_2=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_FChannel); 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); lastLevel_1=0;lastLevel_2=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0;lastLevel_262=0; lastPrice_1=0;lastPrice_2=0;lastPrice_62=0;lastPrice_100=0;lastPrice_162=0;lastPrice_262=0;}return(0);} //+--------Custom indicator iteration function-----------------------+ int start() {datetime c0,cc0,c2,cc2,c4;double c1,c3,cc1,cc3,c5,a,b,c,d,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_FChannel) {if(ObjectFind(UniqueName1)==0) PriceSound_trendline(UniqueName1,LineColor1,Sound1,ArrShift,lastLevel_1,lastPrice_1); if(ObjectFind(UniqueName2)==0) PriceSound_trendline(UniqueName2,LineColor2,Sound2,ArrShift,lastLevel_2,lastPrice_2); 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_100,lastPrice_100); if(ObjectFind(UniqueName5)==0) PriceSound_trendline(UniqueName5,LineColor5,Sound5,ArrShift,lastLevel_162,lastPrice_162); if(ObjectFind(UniqueName5)==0) PriceSound_trendline(UniqueName6,LineColor6,Sound6,ArrShift,lastLevel_262,lastPrice_262); if(ObjectFind(Name_FChannel)==0)ObjectDelete(Name_FChannel);return(0);} if(ObjectFind(Name_FChannel)!=0&&Create_FChannel) {cp=Close[0]+(10+ArrShift)*TradePoint;cp2=cp+ArrShift*TradePoint; ObjectCreate(Name_FChannel,OBJ_FIBOCHANNEL,0,Time[25],cp,Time[0],cp,Time[12],cp2); ObjectSet(Name_FChannel,OBJPROP_COLOR,FChannelColor);ObjectSet(Name_FChannel,OBJPROP_STYLE,1);} else if((ObjectFind(Name_FChannel)==0&&!Create_FChannel)||ObjectFind(Name_FChannel)==0) {if(ObjectFind(Name_FChannel)==0&&!Create_FChannel) {ObjectSet(Name_FChannel,OBJPROP_COLOR,FChannelColor);ObjectSet(Name_FChannel,OBJPROP_STYLE,1);} c0=ObjectGet(Name_FChannel,0);c1=ObjectGet(Name_FChannel,1);c2=ObjectGet(Name_FChannel,2); c3=ObjectGet(Name_FChannel,3);c4=ObjectGet(Name_FChannel,4);c5=ObjectGet(Name_FChannel,5);} else if(ObjectFind(Name_FChannel)!=0){Alert("No FiboChannel - ",Name_FChannel," !");Sleep(3000); return(0);} if(ObjectFind(UniqueName1)!=0) {ObjectCreate(UniqueName1,OBJ_TREND,0,c0,c1,c2,c3);ObjectSetText(UniqueName1,"Price alert level1",0); ObjectSet(UniqueName1,OBJPROP_COLOR,LineColor1);ObjectSet(UniqueName1,OBJPROP_WIDTH,LineWidth1);} if(ObjectFind(UniqueName1)==0) {ObjectMove(UniqueName1,0,c0,c1);ObjectMove(UniqueName1,1,c2,c3); PriceSound_trendline(UniqueName1,LineColor1,Sound1,ArrShift,lastLevel_1,lastPrice_1);} if(ObjectFind(UniqueName2)!=0) {cc1=ObjectGetValueByShift(UniqueName1,c2)+c5; ObjectCreate(UniqueName2,OBJ_TREND,0,c0,cc1,c4,c5);ObjectSetText(UniqueName2,"Price alert level2",0); ObjectSet(UniqueName2,OBJPROP_COLOR,LineColor2);ObjectSet(UniqueName2,OBJPROP_WIDTH,LineWidth2);} if(ObjectFind(UniqueName2)==0) {int t=iBarShift(0,0,c4); a=ObjectGetValueByShift(UniqueName1,t);b=ObjectGet(UniqueName1,1);cc1=b+(c5-a); ObjectMove(UniqueName2,0,c0,cc1);ObjectMove(UniqueName2,1,c4,c5); PriceSound_trendline(UniqueName2,LineColor2,Sound2,ArrShift,lastLevel_2,lastPrice_2);} c=ObjectGet(UniqueName2,1);d=ObjectGet(UniqueName2,3); if(ObjectFind(UniqueName3)!=0) {a=c+0.618*(c-c1);b=d+0.618*(c-c1); ObjectCreate(UniqueName3,OBJ_TREND,0,c0,a,c4,b);ObjectSetText(UniqueName3,"Price alert level3",0); ObjectSet(UniqueName3,OBJPROP_COLOR,LineColor3);ObjectSet(UniqueName3,OBJPROP_WIDTH,LineWidth3);} if(ObjectFind(UniqueName3)==0) {a=c+0.618*(c-c1);b=d+0.618*(c-c1);ObjectMove(UniqueName3,0,c0,a);ObjectMove(UniqueName3,1,c4,b); PriceSound_trendline(UniqueName3,LineColor3,Sound3,ArrShift,lastLevel_62,lastPrice_62);} if(ObjectFind(UniqueName4)!=0) {a=c+(c-c1);b=d+(c-c1); ObjectCreate(UniqueName4,OBJ_TREND,0,c0,a,c4,b);ObjectSetText(UniqueName4,"Price alert level4",0); ObjectSet(UniqueName4,OBJPROP_COLOR,LineColor4);ObjectSet(UniqueName4,OBJPROP_WIDTH,LineWidth4);} if(ObjectFind(UniqueName4)==0) {a=c+(c-c1);b=d+(c-c1);ObjectMove(UniqueName4,0,c0,a);ObjectMove(UniqueName4,1,c4,b); PriceSound_trendline(UniqueName4,LineColor4,Sound4,ArrShift,lastLevel_100,lastPrice_100);} if(ObjectFind(UniqueName5)!=0) {a=c+1.618*(c-c1);b=d+1.618*(c-c1); ObjectCreate(UniqueName5,OBJ_TREND,0,c0,a,c4,b);ObjectSetText(UniqueName5,"Price alert level5",0); ObjectSet(UniqueName5,OBJPROP_COLOR,LineColor5);ObjectSet(UniqueName5,OBJPROP_WIDTH,LineWidth5);} if(ObjectFind(UniqueName5)==0) {a=c+1.618*(c-c1);b=d+1.618*(c-c1);ObjectMove(UniqueName5,0,c0,a);ObjectMove(UniqueName5,1,c4,b); PriceSound_trendline(UniqueName5,LineColor5,Sound5,ArrShift,lastLevel_162,lastPrice_162);} if(ObjectFind(UniqueName6)!=0) {a=c+2.618*(c-c1);b=d+2.618*(c-c1); ObjectCreate(UniqueName6,OBJ_TREND,0,c0,a,c4,b);ObjectSetText(UniqueName6,"Price alert level6",0); ObjectSet(UniqueName6,OBJPROP_COLOR,LineColor6);ObjectSet(UniqueName6,OBJPROP_WIDTH,LineWidth6);} if(ObjectFind(UniqueName6)==0) {a=c+2.618*(c-c1);b=d+2.618*(c-c1);ObjectMove(UniqueName6,0,c0,a);ObjectMove(UniqueName6,1,c4,b); PriceSound_trendline(UniqueName6,LineColor6,Sound6,ArrShift,lastLevel_262,lastPrice_262);}return(0);} //+------------------------------------------------------------------+ void PriceSound_trendline(string UniqueName,color LineColor,string Sound,int arrShift,double lastLevel,double lastPrice) {PipsTextName=StringConcatenate(UniqueName," ","Pips"); ArrShift=arrShift;LastLevel=lastLevel;LastPrice=lastPrice; if(ObjectFind(PipsTextName)==-1) {double cp=LastLevel;if(cp==0)cp=Close[0]+(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 level - 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 level - Inactive",0);ObjectSet(UniqueName,OBJPROP_COLOR,Blue);} if(UniqueName==UniqueName1){lastLevel_1=LastLevel;lastPrice_1=Close[0];} if(UniqueName==UniqueName2){lastLevel_2=LastLevel;lastPrice_2=Close[0];} if(UniqueName==UniqueName3){lastLevel_62=LastLevel;lastPrice_62=Close[0];} if(UniqueName==UniqueName4){lastLevel_100=LastLevel;lastPrice_100=Close[0];} if(UniqueName==UniqueName5){lastLevel_162=LastLevel;lastPrice_162=Close[0];} if(UniqueName==UniqueName6){lastLevel_262=LastLevel;lastPrice_262=Close[0];}} //+------------------------------------------------------------------+