//+------------------------------------------------------------------+ //| PriceSound_trendline.mq4 | //| Roll | //| | //+------------------------------------------------------------------+ /* Источник: индикатор PriceAlert(v.1.1) от api.http://codebase.mql4.com/download/17987. - Индикатор PriceAlert работает с горизонтальной(ми) линией(ми). " Индикатор автоматически определяет момент пересечения ценой линии и активизирует сигнал "(api). - Индикатор PriceSound_trendline работает с трендовой(ми) линией(ми). Для сигнала предпочтение отдается звуку,поэтому звуковой файл должен быть индивидуальным и продолжительностью проигрывания 4-6 сек,а Alert()-ы программно исключены(заменены на PlaySound()). На графике может находится несколько таких трендовых линий с различными названиями (несколько индикаторов PriceSound_trendline). */ #property copyright "Roll" #property indicator_chart_window extern string UniqueName="Trend_Price 1"; extern color LineColor=Pink; extern int LineWidth=2; extern bool Sound_Play=true; extern string Sound="ready.wav"; double LastLevel; double LastPrice; double TradePoint; int ArrShift; string PipsTextName; bool Active; int init() {LastLevel=0;LastPrice=0;Active=true;return(0);} //+------------------------------------------------------------------+ int deinit() { int reason=UninitializeReason(); if(UninitializeReason()==REASON_REMOVE)ObjectDelete(UniqueName); ObjectDelete(PipsTextName);return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if(IndicatorCounted()<20) return; if(Digits==3 || Digits==5) TradePoint=Point*10; else TradePoint=Point; PipsTextName=StringConcatenate(UniqueName," ","Pips"); 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(ObjectFind(UniqueName)==-1) { double cp=LastLevel; if(cp==0)cp=Close[0]+(10+ArrShift)*TradePoint; ObjectCreate(UniqueName,OBJ_TREND,0,Time[20],cp,Time[0],cp); ObjectSetText(UniqueName,"Price alert level",0); ObjectSet(UniqueName,OBJPROP_COLOR,LineColor); ObjectSet(UniqueName,OBJPROP_WIDTH,LineWidth); } if(ObjectFind(PipsTextName)==-1) { cp=LastLevel; if(cp==0)cp=Close[0]+(10+ArrShift)*TradePoint; ObjectCreate(PipsTextName,OBJ_TEXT,0,Time[0],cp); } double newlevel=ObjectGetValueByShift(UniqueName,0); ObjectSet(PipsTextName,OBJPROP_TIME1,Time[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); } LastPrice=Close[0];return(0); } //+------------------------------------------------------------------+