Navigation:Home > Content >

Price_Sound_TS_Dinapoli.mq4

Time: 2011-03-13 | Download file:Price_Sound_TS_Dinapoli.mq4

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#property link "http://forexbig.ru"
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//+------------------------------------------------------------------+
//|                            PriceSoundTS_DinapoliTarget_Malay.mq4 |
//|                                                             Roll |
//|             DinapoliTarget_Malay с функцией PriceSound_trendline |
//+------------------------------------------------------------------+
#property copyright "Roll"
#property link      "http://www.mql4.com/ru/users/Roll"
#property indicator_chart_window
#property indicator_buffers 1
/*1)DinapoliTarget_Malay http://codebase.mql4.com/ru/3034,fxfariz a.k.a warrior trader.
 2)PriceSound_FiboEXPANSION http://codebase.mql4.com/ru/7637.*/
extern int    barn=300;                //история в барах
extern int    Length=6;                //количество баров волны
extern bool   Al=true;                 //вкл. alert
extern bool   targets_Malay=false;     //показать цели "DinapoliTarget_Malay" 
extern bool   PriceSound_on=true;      //вкл. режим "PriceSound_on"
extern bool   Sound_Play=true;         //разрешение на звук
extern string UniqueName1="FiboExpans_62Price 1";//название 1 трендовой линии
extern color  LineColor1=Yellow;       //цвет 1 линии
extern int    LineWidth1=2;            //ширина 1 линии
extern string Sound1="ready.wav";      //название звукового файла для 1 трендовой линии
extern string UniqueName2="FiboExpans_100Price 1";//название 2 трендовой линии
extern color  LineColor2=PaleTurquoise;//цвет 2 линии
extern int    LineWidth2=2;            //ширина 2 линии
extern string Sound2="ready.wav";      //название звукового файла для 2 трендовой линии
extern string UniqueName3="FiboExpans_162Price 1";//название 3 трендовой линии
extern color  LineColor3=LightSkyBlue; //цвет 3 линии
extern int    LineWidth3=2;            //ширина 3 линии
extern string Sound3="ready.wav";      //название звукового файла для 3 трендовой линии
extern string UniqueName4="FiboExpans_262Price 1";//название 4 трендовой линии
extern color  LineColor4=Magenta;      //цвет 4 линии
extern int    LineWidth4=2;            //ширина 4 линии
extern string Sound4="ready.wav";      //название звукового файла для 4 трендовой линии
extern string UniqueName5="FiboExpans_StartPrice 1";//название 5 трендовой линии
extern color  LineColor5=Bisque;       //цвет 5 линии
extern int    LineWidth5=2;            //ширина 5 линии
extern string Sound5="ready.wav";      //название звукового файла для 5 трендовой линии
extern string UniqueName6="FiboExpans_StopPrice 1";//название 6 трендовой линии
extern color  LineColor6=OrangeRed;    //цвет 6 линии
extern int    LineWidth6=2;            //ширина 6 линии
extern string Sound6="ready.wav";      //название звукового файла для 6 трендовой линии
extern bool   Ind_levels=true;         //разрешение/запрет индикации уровней фибо-расширения
extern int    Ind_Bar=0;               //номер бара (смещение) для индикации пунктов
extern int    DistPips=0; //Если меньше 10-авт.установка.Регулировка расстояния от изображения числа пунктов до соотв.прямой
extern color  FExpansColor_levels=Gold;//цвет уровней фибо-расширения
extern string Name_FExpans="FExpans_1";//название фибо-расширения
color  FExpansColor=DarkTurquoise;     //цвет фибо-расширения 
int ArrShift,t;bool Active;string PipsTextName;double LastLevel,LastPrice,TradePoint;
static double lastLevel_Start,lastLevel_Stop,lastLevel_62,lastLevel_100,lastLevel_162,
 lastLevel_262,lastPrice_Start,lastPrice_Stop,lastPrice_62,lastPrice_100,lastPrice_162,lastPrice_262;
double prev,last,alertBar,ExtMapBuffer1[];
//+------------------------------------------------------------------+
int init()
{SetIndexEmptyValue(0,0.0);SetIndexDrawBegin(0,barn);
 SetIndexStyle(0,DRAW_SECTION);SetIndexBuffer(0,ExtMapBuffer1);
 if(Digits==3||Digits==5)TradePoint=Point*10;else TradePoint=Point;LastPrice=0;
 lastLevel_Start=0;lastLevel_Stop=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0;lastLevel_262=0;
 lastPrice_Start=0;lastPrice_Stop=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_FExpans);
  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_Start=0;lastLevel_Stop=0;lastLevel_62=0;lastLevel_100=0;lastLevel_162=0;lastLevel_262=0;
  lastPrice_Start=0;lastPrice_Stop=0;lastPrice_62=0;lastPrice_100=0;lastPrice_162=0;lastPrice_262=0;
  ObjectDelete("Start line");ObjectDelete("Stop line");ObjectDelete("Target1 line");ObjectDelete("Target2 line");
  ObjectDelete("Target3 line");ObjectDelete("Fantnsy line");ObjectDelete("CrazyDream line");}return(0);}
//+------------------------------------------------------------------+
int start()
{int shift,Swing,Swing_n,uzl,i,zu,zd,mv,Line_Width=2;
 double PointA,PointB,PointC,Target1,Target2,Target3,Fantnsy,CrazyDream,Start,Stop,c1,c3,c5,a,b,cp,cp2;
 double LL,HH,BH,BL,NH,NL,Uzel[10000][3],spr=MarketInfo(Symbol(),MODE_SPREAD)*Point;
 color FiboExpan_Color=LightGreen;datetime time_0,time_1,time_2,c0,cc0,c2,cc2,c4; 
 Swing_n=0;Swing=0;uzl=0;BH=High[barn];BL=Low[barn];zu=barn;zd=barn;
 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;}}
 for(shift=barn;shift>=0;shift--) 
 {LL=10000000;HH=-100000000;for(i=shift+Length;i>=shift+1;i--){if(Low[i]HH)HH=High[i];}
  if(Low[shift]HH){Swing=2;if(Swing_n==1)zu=shift+1;if(Swing_n==-1)zd=shift+1;}
  else{if(Low[shift]HH)Swing=1;}
  if(Swing!=Swing_n&&Swing_n!=0)
  {if(Swing==2){Swing=-Swing_n;BH=High[shift];BL=Low[shift];}uzl=uzl+1;
   if(Swing==1){Uzel[uzl][1]=zd;Uzel[uzl][2]=BL;}
   if(Swing==-1){Uzel[uzl][1]=zu;Uzel[uzl][2]=BH;}BH=High[shift];BL=Low[shift];}
  if(Swing==1){if(High[shift]>=BH){BH=High[shift];zu=shift;}}
  if(Swing==-1){if(Low[shift]<=BL){BL=Low[shift];zd=shift;}}Swing_n=Swing;}
  for(i=1;i<=uzl;i++) 
  {mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
   if(prev>Uzel[i][2]&&ExtMapBuffer1[mv]!=Uzel[i][2]&&Al>0&&Bars>alertBar)
   {Alert("Dinapoli Target: BUY SIGNAL ",Symbol()," на ",Period()," минутном графике ");alertBar=Bars;prev=Uzel[i][2];}
   if(prev < Uzel[i][2] && ExtMapBuffer1[mv]!=Uzel[i][2]&&Al>0&&Bars>alertBar)
   {Alert("Dinapoli Target: SELL SIGNAL ",Symbol()," на ",Period()," минутном графике ");alertBar=Bars;prev=Uzel[i][2];}
   ExtMapBuffer1[mv]=Uzel[i][2];}
   PointA=Uzel[uzl-2][2];PointB=Uzel[uzl-1][2];PointC=Uzel[uzl][2];
   Target1=ND((PointB-PointA)*0.618+PointC);Target2=PointB-PointA+PointC;
   Target3=ND((PointB-PointA)*1.618+PointC);Fantnsy=ND((PointB-PointA)*2.618+PointC);
   CrazyDream=ND((PointB-PointA)*4.618+PointC);
   time_0=iTime(0,0,Uzel[uzl-2][1]);time_1=iTime(0,0,Uzel[uzl-1][1]);time_2=iTime(0,0,Uzel[uzl][1]);
 if(PointBPointC){Start= ND((PointB-PointA)*0.318+PointC)+spr;Stop=PointC-2*spr;}
if(targets_Malay==true)
 {if(ObjectFind("Start Line")!=0)
 {ObjectCreate("Start line",OBJ_HLINE,0,Time[0],Start);ObjectSet("Start line",OBJPROP_COLOR,Bisque);
  ObjectSet("Start line",OBJPROP_WIDTH,3);ObjectSet("Start line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Start line",0,Time[0],Start);
 if(ObjectFind("Stop Line")!=0)
  {ObjectCreate("Stop line",OBJ_HLINE,0,Time[0],Stop);ObjectSet("Stop line",OBJPROP_COLOR,Red);
   ObjectSet("Stop line",OBJPROP_WIDTH,3);ObjectSet("Stop line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Stop line",0,Time[0],Stop);
 if(ObjectFind("Target1 Line")!=0)
  {ObjectCreate("Target1 line",OBJ_HLINE,0,Time[0],Target1);ObjectSet("Target1 line",OBJPROP_COLOR,Yellow);
   ObjectSet("Target1 line",OBJPROP_WIDTH,3);ObjectSet("Target1 line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Target1 line",0,Time[0],Target1);
 if(ObjectFind("Target2 Line")!=0)
  {ObjectCreate("Target2 line",OBJ_HLINE,0,Time[0],Target2);ObjectSet("Target2 line",OBJPROP_COLOR,PaleTurquoise);
   ObjectSet("Target2 line",OBJPROP_WIDTH,3);ObjectSet("Target2 line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Target2 line",0,Time[0],Target2);
 if(ObjectFind("Target3 Line")!=0)
 {ObjectCreate("Target3 line",OBJ_HLINE,0,Time[0],Target3);ObjectSet("Target3 line",OBJPROP_COLOR,LightSkyBlue);
  ObjectSet("Target3 line",OBJPROP_WIDTH,3);ObjectSet("Target3 line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Target3 line",0,Time[0],Target3);
 if(ObjectFind("Fantnsy Line")!=0)
 {ObjectCreate("Fantnsy line",OBJ_HLINE,0,Time[0],Fantnsy);ObjectSet("Fantnsy line",OBJPROP_COLOR,Magenta);
  ObjectSet("Fantnsy line",OBJPROP_WIDTH,3);ObjectSet("Fantnsy line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("Fantnsy line",0,Time[0],Fantnsy);
 if(ObjectFind("CrazyDream Line")!=0)
 {ObjectCreate("CrazyDream line",OBJ_HLINE,0,Time[0],Fantnsy);ObjectSet("CrazyDream line",OBJPROP_COLOR,Gold);
  ObjectSet("CrazyDream line",OBJPROP_WIDTH,3);ObjectSet("CrazyDream line",OBJPROP_STYLE,STYLE_DOT);}
 else ObjectMove("CrazyDream line",0,Time[0],CrazyDream);}
 if(targets_Malay==false)
 {ObjectDelete("Start line");ObjectDelete("Stop line");ObjectDelete("Target1 line");ObjectDelete("Target2 line");
  ObjectDelete("Target3 line");ObjectDelete("Fantnsy line");ObjectDelete("CrazyDream line");}
 if(PriceSound_on)
 {if(ObjectFind(Name_FExpans)!=0)
  {ObjectCreate(Name_FExpans,OBJ_EXPANSION,0,time_0,PointA,time_1,PointB,time_2,PointC); 
   ObjectSet(Name_FExpans,OBJPROP_COLOR,FExpansColor);
   ObjectSet(Name_FExpans,OBJPROP_STYLE,1);}
 if(ObjectFind(Name_FExpans)==0)
 {ObjectMove(Name_FExpans,0,time_0,PointA);ObjectMove(Name_FExpans,1,time_1,PointB);ObjectMove(Name_FExpans,2,time_2,PointC);
  if(Ind_levels)
  {ObjectSet(Name_FExpans,OBJPROP_FIBOLEVELS,5);ObjectSet(Name_FExpans,OBJPROP_FIRSTLEVEL,0.33);  
   ObjectSet(Name_FExpans,OBJPROP_FIRSTLEVEL+1,0.618);ObjectSet(Name_FExpans,OBJPROP_FIRSTLEVEL+2,1.0);
   ObjectSet(Name_FExpans,OBJPROP_FIRSTLEVEL+3,1.618);ObjectSet(Name_FExpans,OBJPROP_FIRSTLEVEL+4,2.618);
   ObjectSetFiboDescription(Name_FExpans,0,"START 33.0");ObjectSetFiboDescription(Name_FExpans,1,"COP 61.8");
   ObjectSetFiboDescription(Name_FExpans,2,"OP 100.0");ObjectSetFiboDescription(Name_FExpans,3,"XOP 161.0"); 
   ObjectSetFiboDescription(Name_FExpans,4,"SXOP 261.8");ObjectSet(Name_FExpans,OBJPROP_LEVELCOLOR,FExpansColor_levels);}
  else if(!Ind_levels)ObjectSet(Name_FExpans,OBJPROP_FIBOLEVELS,1); 
  c0=time_0;c1=PointA;c2=time_1;c3=PointB;c4=time_2;c5=PointC;}
 else if(ObjectFind(Name_FExpans)!=0){Alert("No FiboExpans - ",Name_FExpans," !");return(0);}
 a=c3-c1;if(c2>c0){cc0=c0;cc2=c2;}else if(c2=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);}if(Ind_Bar>0)t=Ind_Bar;else t=0;
 ObjectSet(PipsTextName,OBJPROP_TIME1,Time[t]);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_62=LastLevel;lastPrice_62=Close[0];}
 if(UniqueName==UniqueName2){lastLevel_100=LastLevel;lastPrice_100=Close[0];}
 if(UniqueName==UniqueName3){lastLevel_162=LastLevel;lastPrice_162=Close[0];}
 if(UniqueName==UniqueName4){lastLevel_262=LastLevel;lastPrice_262=Close[0];}
 if(UniqueName==UniqueName5){lastLevel_Start=LastLevel;lastPrice_Start=Close[0];}
 if(UniqueName==UniqueName6){lastLevel_Stop=LastLevel;lastPrice_Stop=Close[0];}}
//---------NORMALIZATION---------------------------------------------+
double ND(double v){double digits=MarketInfo(Symbol(),MODE_DIGITS);return(NormalizeDouble(v,digits));}
//+------------------------------------------------------------------+

Recommend