TRUE Forex

Просмотр кода форекс индикатора !!!-MT4 SEMAFOR.mq4

яю// THIS CODE IS POSTED SO THAT LIKE MINDED PAY IT FORWARD CODERS MAY

// IMPROVE ON IT AND REPOST IT ON THE FORUM FOR THEIR FELLOW TRADERS

//==================================================================

// [!!!-MT4 SEMAFOR]                 \¦/

//                                  (B C)

//_____________________________o0o___(_)___o0o______________________ 

#property copyright "Welcome to the World of Forex"

#property indicator_chart_window

#property indicator_buffers 8

   extern bool ShowSemafors=true,SoundAlert=false; bool Trigger1,Trigger2,Trigger3,Trigger4;

  extern string myUpperSoundFile="alert.wav",myLowerSoundFile="alert.wav";

  extern string DevStep1="1,1",DevStep2="1,1",DevStep3="1,1",DevStep4="1,1";

  string symbol,tChartPeriod;

    extern  int Period1=21,Period2=40,Period3=40,Period4=72;

    int digits,period,OldBars=-1,CountBars=1700,shfX,Type;

    extern  int SYM1=108,SYM2=108,SYM3=162,SYM4=162;

  extern string TT="*******************************";

    extern  int 8=8O_" =2;

    extern color &25B_" =clrWhite;

    extern  int 8=8O_F =2;

    extern color &25B_F =clrWhite;

    extern  int 8=8O_E =2;

    extern color &25B_E =clrLime;

    extern  int 8=8O_G =2;

    extern color &25B_G =clrLime;

      int lvl1DN,lvl1UP,lvl2DN,lvl2UP,lvl3DN,lvl3UP,lvl4DN,lvl4UP,Dev1,Stp1,Dev2,Stp2,Dev3,Stp3,Dev4,Stp4;

      int Sema1dn[2],Sema1up[2],Sema2dn[2],Sema2up[2],Sema3dn[2],Sema3up[2],Sema4dn[2],Sema4up[2];    

   double Level1UP[],Level1DN[],Level2UP[],Level2DN[],Level3UP[],Level3DN[],Level4UP[],Level4DN[],point,

   Semafor1dn[2],Semafor1up[2],Semafor2dn[2],Semafor2up[2],Semafor3dn[2],Semafor3up[2],Semafor4dn[2],Semafor4up[2];     

//+------------------------------------------------------------------------------------------------------------------+

   int init() {int Buf=-1,Mass[]; period=Period(); tChartPeriod=TimeFrameToString(period);

   symbol=Symbol(); digits=Digits; point=Point; if(digits==5||digits==3) {digits--; point=10.0*point;}

//+------------------------------------------------------------------------------------------------------------------+

   if(ShowSemafors) Type=DRAW_ARROW; else Type=DRAW_NONE;

   if(Period1>0.0){   

   Buf+=1;SetIndexBuffer(Buf,Level1UP);SetIndexStyle(Buf,Type,EMPTY,8=8O_",&25B_");SetIndexArrow(Buf,SYM1);

   Buf+=1;SetIndexBuffer(Buf,Level1DN);SetIndexStyle(Buf,Type,EMPTY,8=8O_",&25B_");SetIndexArrow(Buf,SYM1);}

   if(Period2>0.0){

   Buf+=1;SetIndexBuffer(Buf,Level2UP);SetIndexStyle(Buf,Type,EMPTY,8=8O_F,&25B_F);  SetIndexArrow(Buf,SYM2);

   Buf+=1;SetIndexBuffer(Buf,Level2DN);SetIndexStyle(Buf,Type,EMPTY,8=8O_F,&25B_F);  SetIndexArrow(Buf,SYM2);}

   if(Period3>0.0){

   Buf+=1;SetIndexBuffer(Buf,Level3UP);SetIndexStyle(Buf,Type,EMPTY,8=8O_E,&25B_E);SetIndexArrow(Buf,SYM3);

   Buf+=1;SetIndexBuffer(Buf,Level3DN);SetIndexStyle(Buf,Type,EMPTY,8=8O_E,&25B_E);SetIndexArrow(Buf,SYM3);}

   if(Period4>0.0){

   Buf+=1;SetIndexBuffer(Buf,Level4UP);SetIndexStyle(Buf,Type,EMPTY,8=8O_G,&25B_G); SetIndexArrow(Buf,SYM4);

   Buf+=1;SetIndexBuffer(Buf,Level4DN);SetIndexStyle(Buf,Type,EMPTY,8=8O_G,&25B_G); SetIndexArrow(Buf,SYM4);}

//+------------------------------------------------------------------------------------------------------------------+

   int C=0; if(IntFromStr(DevStep1,C,Mass)==1){Stp1=Mass[1];Dev1=Mass[0];}

            if(IntFromStr(DevStep2,C,Mass)==1){Stp2=Mass[1];Dev2=Mass[0];}

            if(IntFromStr(DevStep3,C,Mass)==1){Stp3=Mass[1];Dev3=Mass[0];}

            if(IntFromStr(DevStep4,C,Mass)==1){Stp4=Mass[1];Dev4=Mass[0];} return(0);}

//+------------------------------------------------------------------------------------------------------------------+

   int deinit() {return(0);}

   int  start() {deinit(); if(Bars!=OldBars){Trigger1=TRUE; Trigger2=TRUE; Trigger3=TRUE; Trigger4=TRUE;}

   if(Period1>0.0) CountZZ(Level1UP,Period1); if(Period2>0.0) CountZZ(Level2UP,Period2);

   if(Period3>0.0) CountZZ(Level3UP,Period3); if(Period4>0.0) CountZZ(Level4UP,Period4);

//+------------------------------------------------------------------------------------------------------------------+

   if(Trigger1) {if(Level1UP[0]!=0.0) {Trigger1=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level1DN "+DoubleToStr(Close[0],digits));}

   if(Level1DN[0]!=0.0) {Trigger1=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level1UP "+DoubleToStr(Close[0],digits));}}

//+------------------------------------------------------------------------------------------------------------------+

   if(Trigger2) {if(Level2UP[0]!=0.0) {Trigger2=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level2DN "+DoubleToStr(Close[0],digits));}

   if(Level2DN[0]!=0.0) {Trigger2=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level2UP "+DoubleToStr(Close[0],digits));}}

//+------------------------------------------------------------------------------------------------------------------+   

   if(Trigger3) {if(Level3UP[0]!=0.0) {Trigger3=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level3DN "+DoubleToStr(Close[0],digits));}

   if(Level3DN[0]!=0.0) {Trigger3=FALSE;

   if(SoundAlert)Alert(symbol," ",tChartPeriod," Level3UP "+DoubleToStr(Close[0],digits));}}

//+------------------------------------------------------------------------------------------------------------------+

   if(Trigger4) {if(Level4UP[0]!=0.0) {Trigger4=FALSE;

   if(SoundAlert)Alert(symbol,"  ",tChartPeriod," Level 4 Lower "+DoubleToStr(Close[0],digits));}

   if(Level4DN[0]!=0.0) {Trigger4=FALSE;

   if(SoundAlert)Alert(symbol,"  ",tChartPeriod," Level 4 Upper "+DoubleToStr(Close[0],digits));}}

//+------------------------------------------------------------------------------------------------------------------+

   lvl4DN=0;lvl4UP=0;lvl3DN=0;lvl3UP=0;lvl2DN=0;lvl2UP=0;lvl1DN=0;lvl1UP=0; for(shfX=0;shfX<1000;shfX++){

         if(Level4UP[shfX]!=0.0 && lvl4UP<2){Sema4up[lvl4UP]=shfX;Semafor4up[lvl4UP]=Level4UP[shfX];lvl4UP++;} 

   else {if(Level4DN[shfX]!=0.0 && lvl4DN<2){Sema4dn[lvl4DN]=shfX;Semafor4dn[lvl4DN]=Level4DN[shfX];lvl4DN++;}

   else {if(Level3UP[shfX]!=0.0 && lvl3UP<2){Sema3up[lvl3UP]=shfX;Semafor3up[lvl3UP]=Level3UP[shfX];lvl3UP++;}

   else {if(Level3DN[shfX]!=0.0 && lvl3DN<2){Sema3dn[lvl3DN]=shfX;Semafor3dn[lvl3DN]=Level3DN[shfX];lvl3DN++;} 

   else {if(Level2UP[shfX]!=0.0 && lvl2UP<2){Sema2up[lvl2UP]=shfX;Semafor2up[lvl2UP]=Level2UP[shfX];lvl2UP++;}

   else {if(Level2DN[shfX]!=0.0 && lvl2DN<2){Sema2dn[lvl2DN]=shfX;Semafor2dn[lvl2DN]=Level2DN[shfX];lvl2DN++;}

   else {if(Level1UP[shfX]!=0.0 && lvl1UP<2){Sema1up[lvl1UP]=shfX;Semafor1up[lvl1UP]=Level1UP[shfX];lvl1UP++;}

   else {if(Level1DN[shfX]!=0.0 && lvl1DN<2){Sema1dn[lvl1DN]=shfX;Semafor1dn[lvl1DN]=Level1DN[shfX];lvl1DN++;}}}}}}}} 

   if(lvl3UP>=2 && lvl3DN>=2 && lvl2UP>=2 && lvl2DN>=2 && lvl1UP>=2 && lvl1DN>=2) break;} return(0);}

//+------------------------------------------------------------------------------------------------------------------+

   string TimeFrameToString(int tf){string tfs; switch (tf){case     1:tfs="M1";  break;

                                                            case     5:tfs="M5";  break;

                                                            case    15:tfs="M15"; break;

                                                            case    30:tfs="M30"; break;

                                                            case    60:tfs="H1";  break;

                                                            case   240:tfs="H4";  break;

                                                            case  1440:tfs="D1";  break;

                                                            case 10080:tfs="W1";  break;

                                                            case 43200:tfs="MN";} return (tfs);}

//+------------------------------------------------------------------------------------------------------------------+

   int CountZZ(double &buffer[],int Length){int shift,zu,zd,Swing,Swing_n; double HH,LL,BH,BL;

   Swing=0; Swing_n=0; shift=CountBars-1; zu=shift; zd=shift; BH=High[shift]; BL=Low[shift];

//+------------------------------------------------------------------------------------------------------------------+

   for(shift=CountBars-1;shift>=0;shift--){

   HH=High[Highest(NULL,0,MODE_HIGH,Length,shift+1)]; LL=Low[Lowest (NULL,0,MODE_LOW,Length,shift+1)];

   if(Low[shift]<LL && High[shift]>HH) {Swing=2; if(Swing_n==1) zu=shift+1; if(Swing_n==-1) zd=shift+1;}

   else {if(Low[shift]<LL) Swing=-1; if(High[shift]>HH) Swing=1;} if(Swing!=Swing_n && Swing_n!=0) {

   if(Swing== 2) {Swing=-Swing_n; BH=High[shift]; BL=Low[shift];}

   if(Swing== 1) buffer[zd]=BL;

   if(Swing==-1) buffer[zu]=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;} return(0);}

//+------------------------------------------------------------------------------------------------------------------+

   int Str2Massive(string VStr,int &M_Count,int &VMass[]) {int val=StrToInteger(VStr); if(val>0) {M_Count++;

   int mc=ArrayResize(VMass,M_Count); if(mc==0)return(-1); VMass[M_Count-1]=val; return(1);} return(0);}

//+------------------------------------------------------------------------------------------------------------------+

   int IntFromStr(string VStr,int &M_Count,int &VMass[]) {if(StringLen(VStr)==0) return(-1);

   string SS=VStr,CS; int NP=0; M_Count=0; ArrayResize(VMass,M_Count); while(StringLen(SS)>0){

   NP=StringFind(SS,","); if(NP>0) {CS=StringSubstr(SS,0,NP); SS=StringSubstr(SS,NP+1,StringLen(SS));}

   else {if(StringLen(SS)>0){CS=SS; SS="";}} if(Str2Massive(CS,M_Count,VMass)==0) return(-2);} return(1);}

//+------------------------------------------------------------------------------------------------------------------+

Комментарии к исходному коду форекс индикатора !!!-MT4 SEMAFOR.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !!! Fractal.Arrow.mq4
индикатор !!!-MT4 X-HEATMAP (2).mq4 »