Miscellaneous
0
Views
0
Downloads
0
Favorites
PriceSound_channel
//+------------------------------------------------------------------+
//| PriceSound_channel.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 ðàáîòàåò ñ òðåíäîâîé(ìè) ëèíèåé(ìè)
Äëÿ ñèãíàëà ïðåäïî÷òåíèå îòäàåòñÿ çâóêó,ïîýòîìó çâóêîâîé ôàéë äîëæåí áûòü èíäèâèäóàëüíûì è
ïðîäîëæèòåëüíîñòüþ ïðîèãðûâàíèÿ íåñêîëüêî ñåêóíä).
Íà ãðàôèêå ìîæåò íàõîäèòñÿ íåñêîëüêî òàêèõ òðåíäîâûõ ëèíèé ñ ðàçëè÷íûìè íàçâàíèÿìè
(íåñêîëüêî èíäèêàòîðîâ PriceSound_trendline).
=======================================================================
- Èíäèêàòîð PriceSound_channel ðàáîòàåò ñ "êàíàëàìè",êîòîðûå ñîïðîâîæäàþò òðåíäîâûå ëèíèè.
Ðàáîòàåò â òåñòåðå.
 èíäèêàòîðå èñïîëüçóåòñÿ ôóíêöèÿ,âûïîëíåííàÿ èç èíäèêàòîðà PriceSound_trendline.
Òî åñòü èíäèêàòîð PriceSound_channel èìååò ñâîéñòâà,õàðàêòåðíûå äëÿ èíäèêàòîðà PriceSound_trendline.
========================================================================
*/
extern bool Sound_Play=true; //ðàçðåøåíèå íà çâóê
extern string UniqueName1="Trend_Price 1";//íàçâàíèå 1 òðåíäîâîé ëèíèè
extern color LineColor1=Pink; //öâåò 1 ëèíèè
extern int LineWidth1=2; //øèðèíà 1 ëèíèè
extern string Sound1="ready.wav"; //íàçâàíèå çâóêîâîãî ôàéëà äëÿ 1 òðåíäîâîé ëèíèè
extern string UniqueName2="Trend_Price 2";//íàçâàíèå 2 òðåíäîâîé ëèíèè
extern color LineColor2=YellowGreen; //öâåò 2 ëèíèè
extern int LineWidth2=2; //øèðèíà 2 ëèíèè
extern string Sound2="ready.wav"; //íàçâàíèå çâóêîâîãî ôàéëà äëÿ 2 òðåíäîâîé ëèíèè
extern color ChannelColor=DarkTurquoise; //öâåò êàíàëà
extern bool Create_Channel=true; //ðàçðåøåíèå/çàïðåò íà îáðàçîâàíèå êàíàëà
extern string Name_Channel="Channel_1"; //íàçâàíèå êàíàëà
extern bool Del_Channel=false; //çàïðåò/ðàçðåøåíèå íà óäàëåíèå çàäàííîãî êàíàëà
int ArrShift;bool Active;string PipsTextName;
double LastLevel,LastPrice,TradePoint;
static double lastLevel_1,lastLevel_2,lastPrice_1,lastPrice_2;
int init()
{if(Digits==3||Digits==5)TradePoint=Point*10;else TradePoint=Point;
LastPrice=0;lastLevel_1=0;lastLevel_2=0;lastPrice_1=0;lastPrice_2=0;Active=true;return(0);}
int deinit()
{if(UninitializeReason()==REASON_REMOVE)
{ObjectDelete(Name_Channel);ObjectDelete(UniqueName1);ObjectDelete(UniqueName2);PipsTextName=UniqueName1+" Pips";ObjectDelete(PipsTextName);
PipsTextName=UniqueName2+" Pips";ObjectDelete(PipsTextName);lastLevel_2=0;lastLevel_1=0;}return(0);}
//+--------Custom indicator iteration function-----------------------+
int start()
{datetime c0,cc0,c2,cc2,c4;double c1,c3,cc1,cc3,c5,a,b,c,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_Channel)
{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(Name_Channel)==0)ObjectDelete(Name_Channel);return(0);}
if(ObjectFind(Name_Channel)!=0&&Create_Channel)
{cp=Close[0]+(10+ArrShift)*TradePoint;cp2=cp+ArrShift*TradePoint;
ObjectCreate(Name_Channel,OBJ_CHANNEL,0,Time[25],cp,Time[0],cp,Time[12],cp2);
ObjectSet(Name_Channel,OBJPROP_COLOR,ChannelColor);
ObjectSet(Name_Channel,OBJPROP_STYLE,1);}
else if((ObjectFind(Name_Channel)==0&&!Create_Channel)||ObjectFind(Name_Channel)==0)
{if(ObjectFind(Name_Channel)==0&&!Create_Channel)
{ObjectSet(Name_Channel,OBJPROP_COLOR,ChannelColor);
ObjectSet(Name_Channel,OBJPROP_STYLE,1);}
c0=ObjectGet(Name_Channel,0);c1=ObjectGet(Name_Channel,1);c2=ObjectGet(Name_Channel,2);
c3=ObjectGet(Name_Channel,3);c4=ObjectGet(Name_Channel,4);c5=ObjectGet(Name_Channel,5);}
else if(ObjectFind(Name_Channel)!=0){Alert("No Channel - ",Name_Channel," !");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)
{a=ObjectGetValueByShift(UniqueName1,c2);a=a+c5;cc1=a;
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);}
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]<newlevel)ObjectSet(PipsTextName,OBJPROP_PRICE1,newlevel+ArrShift*TradePoint);
if(LastLevel!=newlevel)
{LastLevel=newlevel;LastPrice=0;ObjectSetText(UniqueName,"Price sound level - Active",0);Active=true;}
if(Active&&LastPrice!=0&&((LastPrice<LastLevel&&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];}}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---