Divergence Fractal RSI

Author: февраль 2020, ROMANBEST
Indicators Used
Relative strength indexMACD HistogramFractals
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Divergence Fractal RSI
ÿþ//+---------------------------------------------------------------------------------

//|                                                  I DIVERGENCE RSI.mq4

//|  "   & -  !!" ."!/   !% $ " (  5  )  "   

//|   "!/ 5 $ " ! !" "   !!" "!/  &/ ' &+   5-% $ " ! !" "+ 

//|  !""!"#.)% ' "    "!!!"" -!" #

//|

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

#property copyright   " D52@0;L 2020, ROMANBEST "

#property link        " http://www.mql4.com "

#property description " I DIVERGENCE RSI"

#property strict





//--- indicator settings

#property indicator_chart_window    // =48:. @8AC5BAO 2 >A=>2=>< >:=5



//  ! ( %#) -  UP-FRATALS

#property indicator_buffers 7       // >;8G5AB2> 1CD5@>2

#property indicator_color1 Red      // &25B ?5@2>9 ;8=88

#property indicator_color2 Red      // &25B 2 ;8=88

#property indicator_color6 FireBrick





//   (#) -  DW-FRATALS

#property indicator_color3 Green      // &25B 3 ;8=88

#property indicator_color4 Green      // &25B 2B>@>9 ;8=88

#property indicator_color5 Indigo















//--- input parameters

input int     RSIPeriod = 14;       //   RSI



double Buf_0[],Buf_1[];   // 1JO2;5=85 <0AA82>2 (?>4 1CD5@K 8=48:0B>@0)   ! ( %#) -  UP-FRATALS



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

//|                                                                  |

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

double Buf_2[],Buf_3[];   // 1JO2;5=85 <0AA82>2 (?>4 1CD5@K 8=48:0B>@0)    (#) -  DW-FRATALS

double Buf_4[],Buf_5[];   // 07=0G5=85 <0AA820  &







double MacdCurrent,MacdPrevious, MacdPrevPrevious;

double MacdNext,MacdNextNext;



double _RSICurrent,_RSIPrevious, _RSIPrevPrevious;

double _RSINext,_RSINextNext;



double SignalCurrent,SignalPrevious;

// double MaCurrent,MaPrevious;









double FRACTAL;



//--------------------------------------------------------------------

int init()                          // !?5F80;L=0O DC=:F8O init()

  {

   SetIndexBuffer(0,Buf_0);         // 07=0G5=85 <0AA820 1CD5@C  ! ( %#) - !"  % 

   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,4,clrRed); //

   SetIndexArrow(0, SYMBOL_ARROWDOWN);

   SetIndexBuffer(1,Buf_1);         // 07=0G5=85 <0AA820 1CD5@C  UP-FRATALS

   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,2,clrRed); // !B8;L ;8=88

   SetIndexArrow(1, SYMBOL_CHECKSIGN);

   SetIndexBuffer(5,Buf_5);         // 07=0G5=85 <0AA820  & 1CD5@C    ! ( %#) - !"  % 

   SetIndexStyle(5,DRAW_ARROW,STYLE_SOLID,5,clrFireBrick); // !B8;L ;8=88

   SetIndexArrow(5, SYMBOL_CHECKSIGN);









   SetIndexBuffer(2,Buf_2);         // 07=0G5=85 <0AA820 1CD5@C    (#) - !"  %  %

   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,4,clrGreen); // !B8;L ;8=88

   SetIndexArrow(2, SYMBOL_ARROWUP);

   SetIndexBuffer(3,Buf_3);         // 07=0G5=85 <0AA820 1CD5@C   DW-FRATALS

   SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,2,clrGreen); // !B8;L ;8=88

   SetIndexArrow(3, SYMBOL_CHECKSIGN);

   SetIndexBuffer(4,Buf_4);         // 07=0G5=85 <0AA820  & 1CD5@C    (#) - !"  %  %

   SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,5,clrIndigo); // !B8;L ;8=88

   SetIndexArrow(4, SYMBOL_CHECKSIGN);







//IndicatorShortName ("I Div");







   return(0);                          // KE>4 87 A?5F. D-88 init()

  }

//--------------------------------------------------------------------

int start()                         // !?5F80;L=0O DC=:F8O start()

  {

   int i,                           // =45:A 10@0

       Counted_bars;                // >;8G5AB2> ?@>AG8B0==KE 10@>2



//--------------------------------------------------------------------

   Buf_0[0] = 0;

   Buf_2[0] = 0;







   Counted_bars=IndicatorCounted(); // >;8G5AB2> ?@>AG8B0==KE 10@>2

   i=Bars-Counted_bars-1;           // =45:A ?5@2>3> =5?>AG8B0==>3>



   FRACTAL = GetLastFrac(Symbol(),0,2);

//Print("  + D@0:B0;: ", FRACTAL);











   /*

    while(i>=0)                       // &8:; ?> =5?>AG8B0==K< 10@0<

      {

   //------------------------------ 70?><8=05< F5=C ! $ "

      if (FRACTAL == 0)               // =5B D@0:B0;0

      if (FRACTAL < 0)

        FRACTAL = MathAbs(FRACTAL);   // @01>B05< A =86=8< D@0:B0;><

      if (FRACTAL > 0)                // @01>B05< A 25@E=8< D@0:B0;><



   //-------------------------------------------------------------------------



       _RSICurrent =  iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);

       _RSIPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);

       _RSIPrevPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+2);

       _RSINext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-1);

       _RSINextNext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-2);





       MacdCurrent =iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_MAIN,i);

       MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_OPEN,MODE_MAIN,i+1);







   //     if(MacdCurrent < MacdPrevious && MaCurrent < MaPrevious)

   //       Buf_0[i]=Open[i];           // =0G5=85 0 1CD5@0 =0 i->< 10@5





   //    if(MacdCurrent > MacdPrevious && MaCurrent > MaPrevious) // 4;O 1052

   //    Buf_1[i]=Open[i];              // =0G5=85 1 1CD5@0 =0 i->< 10@5







       i--;                          //  0AGQB 8=45:A0 A;54CNI53> 10@0

      }



   */

//--------------------------------------------------------------------

   return(0);                          // KE>4 87 A?5F. D-88 start()

  }



//---------------------------------------------------------------   GetLastFrac_UP +,  GetLastFrac_DW -

double GetLastFrac(string smb, int tf, int iB)

  {

   int =><5@_10@0_0 = 0,     // =><5@ 10@0 D@0:B0;0

                          =><5@_10@0_1 = 0,

                                             =><5@_10@0_2 = 0,

                                                                =><5@_10@0_3 = 0,

                                                                                   =><5@_10@0_4 = 0,

                                                                                                      =><5@_10@0_5 = 0,





                                                                                                                         n=iBars(smb, tf);



   double

   frac_0 = 0, RSI_0 = 0,

   frac_1 = 0, RSI_1 = 0,

   frac_2 = 0, RSI_2 = 0,

   frac_3 = 0, RSI_3 = 0,

   frac_4 = 0, RSI_4 = 0,

   frac_5 = 0, RSI_5 = 0;



   double RSICurrent,RSIPrevious, RSIPrevPrevious;

   double RSINext,RSINextNext;



   for(int i=iB; i<n; i++)               // F8:; A =C;52>3> 10@0 23;C1L 8AB>@88, :0: =0H;8 ?5@2K9 (!" "+) - ?5@5H;8 : A;54CNI5<C

     {



      frac_0 = iFractals(smb, tf, MODE_UPPER, i);

      if(frac_0 > 0 && =><5@_10@0_0 == 0)

        {

         =><5@_10@0_0 = i;

         Print(" !" "+ D@0:B0; UP: ", frac_0, " =0 10@5 ! ", =><5@_10@0_0," ?@>25@:0 =0;8G8O B>G5: ?5@5381>2 8 A>>A=>AB8... ");

         //Buf_1[i] = frac_0; // EMPTY_VALUE;



         // =0;8G85 B>G5: ?5@53810 A RSI 8 A>>A=>ABL A iFractals

         RSICurrent =  iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);        // 10@K 3

         RSIPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);      // 4

         RSIPrevPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+2);  // 5

         RSINext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-1);          // 2

         RSINextNext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-2);      // 1



         if((RSICurrent > RSINext && RSICurrent > RSIPrevious) || (RSICurrent < RSIPrevious && RSIPrevious > RSIPrevPrevious) ||

            (RSICurrent < RSINext && RSINext > RSINextNext) || (RSICurrent > RSIPrevPrevious && RSICurrent > RSINext)         ||

            (RSIPrevPrevious < RSIPrevious && RSIPrevious > RSINext) || (RSICurrent > RSIPrevPrevious &&  RSICurrent > RSINextNext) ||

            (RSINext > RSIPrevious && RSINext > RSINextNext) || (RSIPrevPrevious < RSINext && RSINext > RSINextNext)          ||

            (RSICurrent > RSIPrevious && RSICurrent > RSINextNext))

           {

            Print(" ' B>G5: ?5@53810 RSI 8 A>>A=>AB8 A> AB0@B>2K< UP - D@0:B0;>< ");

            Buf_1[=><5@_10@0_0] = frac_0;

            RSI_0 = RSICurrent;

            break;

            //return(-frac_0);

           }

         else

           {

            Print(" "!#"!" B>G5: ?5@53810 RSI 8 A>>A=>AB8 A> AB0@B>2K< UP - D@0:B0;>< ");

            Buf_1[=><5@_10@0_0] = NULL;

            RSI_0 = 0;

            // Buf_2[i] = RSICurrent;

            break;

            // return(-frac_0);

           }



         //Buf_1[i]=Open[i];

         // return(frac_0);

        }







      //  !'" '/  !!!" !" "  $ "

      frac_0 = iFractals(smb, tf, MODE_LOWER, i);



      if(frac_0 > 0 && =><5@_10@0_0 == 0)

        {

         =><5@_10@0_0 = i;

         Print(" !" "+ D@0:B0; DW: ", frac_0, " =0 10@5 ! ", =><5@_10@0_0, " ?@>25@:0 =0;8G8O B>G5: ?5@5381>2 8 A>>A=>AB8... ");



         // =0;8G85 B>G5: ?5@53810 A RSI 8 A>>A=>ABL A ?5@2K< (D@0:B0;><)

         RSICurrent =  iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);        // 10@K 3

         RSIPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);      // 4

         RSIPrevPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+2);  // 5

         RSINext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-1);          // 2

         RSINextNext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-2);      // 1



         if((RSICurrent < RSINext && RSICurrent < RSIPrevious) || (RSICurrent > RSIPrevious && RSIPrevious < RSIPrevPrevious) ||

            (RSICurrent > RSINext && RSINext < RSINextNext) || (RSICurrent < RSIPrevPrevious && RSICurrent < RSINext)         ||

            (RSIPrevPrevious > RSIPrevious && RSIPrevious < RSINext) || (RSICurrent < RSIPrevPrevious &&  RSICurrent < RSINextNext) ||

            (RSINext < RSIPrevious && RSINext < RSINextNext) || (RSIPrevPrevious > RSINext && RSINext < RSINextNext)          ||

            (RSICurrent < RSIPrevious && RSICurrent < RSINextNext))

           {

            Print(" ' B>G5: ?5@53810 RSI 8 A>>A=>AB8 A> AB0@B>2K< DW - D@0:B0;>< ");

            Buf_3[=><5@_10@0_0]= frac_0;

            RSI_0 = RSICurrent;

            frac_0 = -frac_0;

            break;

            //return(-frac_0);

           }

         else

           {

            Print(" "!#"!" B>G5: ?5@53810 RSI 8 A>>A=>AB8 A> AB0@B>2K< DW - D@0:B0;>< ");

            Buf_3[=><5@_10@0_0]= NULL;

            frac_0 = -frac_0;

            RSI_0 = 0;

            break;

            // return(-frac_0);

           }







        }

     } // : for (int i=iB; i<n; i++)



//--------------------------------------------------------------------------------------------------------





// @0AG5B   $ " UP  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> ?5@2><C UP D@0:B0;C



   if(Buf_1[=><5@_10@0_0] > 0 && frac_0 > 0)

     {

      =><5@_10@0_1 = !!!",(_Symbol, 0, =><5@_10@0_0+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_1 > 0)

         if(Buf_1[=><5@_10@0_1] > 0  && Buf_1[=><5@_10@0_1] < Buf_1[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_1) >  RSI_0 && RSI_0 !=0 && =><5@_10@0_1 > =><5@_10@0_0 + 5)

           {



            Buf_0[0]=Open[0];  //  !# DW !" # 2E>40 2=87

            Buf_5[=><5@_10@0_1] = iFractals(_Symbol, 0, MODE_UPPER, =><5@_10@0_1);

            Buf_4[=><5@_10@0_1] = 0;

            Buf_2[0]=NULL;

            Print(" !!!!",  &/   # UP D@0:B0;C, @8AC5< 2E>4 2 !,  Buf_0[0] = ",  Buf_0[0],

                  " Buf_2[0] = ",  Buf_2[0]);

           }



         else

           {

            Buf_0[0]=NULL;

            Print(" "  & ?>  # UP D@0:B0;C ");

           }

     }



// @0AG5B   $ " DW  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> ?5@2><C DW D@0:B0;C

   if(Buf_3[=><5@_10@0_0] > 0 && frac_0 < 0)

     {

      =><5@_10@0_1 = !!!",(_Symbol, 0, =><5@_10@0_0+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_1 > 0)

         if(Buf_3[=><5@_10@0_1] > 0  && Buf_3[=><5@_10@0_1] > Buf_3[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_1) <  RSI_0 && RSI_0 !=0 && =><5@_10@0_1 > =><5@_10@0_0 + 5)

           {



            Buf_2[0]=Open[0];  //  !# UP !" # 2E>40 UP

            Buf_4[=><5@_10@0_1] = iFractals(_Symbol, 0, MODE_LOWER, =><5@_10@0_1);

            Buf_5[=><5@_10@0_1] = 0;

            Buf_0[0]=NULL;

            Print(" !!!!",  &/   # DW D@0:B0;C, @8AC5< 2E>4 2 ,  Buf_2[0] = ",  Buf_2[0],

                  " Buf_0[0] = ",  Buf_0[0]);

           }



         else

           {

            Buf_2[0]=NULL;

            Print(" "  & ?>  # DW D@0:B0;C ");

           }

     }

//-----------------------------------------------------------------------------------------------------------------------------------





// @0AG5B "  $ " UP  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> " # UP D@0:B0;C



   if(Buf_1[=><5@_10@0_0] > 0 && frac_0 > 0)

     {

      =><5@_10@0_2 = !!!",(_Symbol, 0, =><5@_10@0_1+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_2 > 0)

         if(Buf_1[=><5@_10@0_2] > 0  && Buf_1[=><5@_10@0_2] < Buf_1[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_2) > RSI_0 && RSI_0 !=0)

           {



            Buf_0[0]=Open[0];// - 5*Point;  //  !# DW !" # 2E>40 2=87

            Buf_5[=><5@_10@0_2] = iFractals(_Symbol, 0, MODE_UPPER, =><5@_10@0_2);

            Buf_4[=><5@_10@0_2] = 0;

            Buf_2[0]=NULL;

            Print(" !!!!",  &/  " # UP D@0:B0;C, @8AC5< 2E>4 2 !,  Buf_0[0] = ",  Buf_0[0],

                  " Buf_2[0] = ",  Buf_2[0]);

           }



         else

            Print(" "  & ?> " # UP D@0:B0;C ");//Buf_0[0]=0;}

     }



// @0AG5B "  $ " DW  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> " # DW D@0:B0;C

   if(Buf_3[=><5@_10@0_0] > 0 && frac_0 < 0)

     {

      =><5@_10@0_2 = !!!",(_Symbol, 0, =><5@_10@0_1+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_2 > 0)

         if(Buf_3[=><5@_10@0_2] > 0  && Buf_3[=><5@_10@0_2] > Buf_3[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_2) <  RSI_0 && RSI_0 !=0)

           {



            Buf_2[0]=Open[0];// + 5*Point;  //  !# UP !" # 2E>40 UP

            Buf_4[=><5@_10@0_2] = iFractals(_Symbol, 0, MODE_LOWER, =><5@_10@0_2);

            Buf_5[=><5@_10@0_2] = 0;

            Buf_0[0]=NULL;

            Print(" !!!!",  &/  " # DW D@0:B0;C, @8AC5< 2E>4 2 ,  Buf_2[0] = ",  Buf_2[0],

                  " Buf_0[0] = ",  Buf_0[0]);

           }



         else

            Print(" "  & ?> " # DW D@0:B0;C ");  //Buf_2[0]=0;}

     }

//-----------------------------------------------------------------------------------------------------------------------------------







// @0AG5B " ", $ " UP  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> " ",# UP D@0:B0;C



   if(Buf_1[=><5@_10@0_0] > 0 && frac_0 > 0)

     {

      =><5@_10@0_3 = !!!",(_Symbol, 0, =><5@_10@0_2+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_3 > 0)

         if(Buf_1[=><5@_10@0_3] > 0  && Buf_1[=><5@_10@0_3] < Buf_1[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_3) > RSI_0 && RSI_0 !=0)

           {



            Buf_0[0]=Open[0];// - 10*Point;  //  !# DW !" # 2E>40 2=87

            Buf_5[=><5@_10@0_3] = iFractals(_Symbol, 0, MODE_UPPER, =><5@_10@0_3);

            Buf_4[=><5@_10@0_3] = 0;

            Buf_2[0]=NULL;

            Print(" !!!!",  &/  " ",# UP D@0:B0;C, @8AC5< 2E>4 2 !,  Buf_0[0] = ",  Buf_0[0],

                  " Buf_2[0] = ",  Buf_2[0]);

           }



         else

            Print(" "  & ?> " ",# UP D@0:B0;C ");//Buf_0[0]=0;}

     }



// @0AG5B " ", $ " DW  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> " ",# DW D@0:B0;C

   if(Buf_3[=><5@_10@0_0] > 0 && frac_0 < 0)

     {

      =><5@_10@0_3 = !!!",(_Symbol, 0, =><5@_10@0_2+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_3 > 0)

         if(Buf_3[=><5@_10@0_3] > 0  && Buf_3[=><5@_10@0_3] > Buf_3[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_3) <  RSI_0 && RSI_0 !=0)

           {



            Buf_2[0]=Open[0]; //+ 10*Point;  //  !# UP !" # 2E>40 UP

            Buf_4[=><5@_10@0_3] = iFractals(_Symbol, 0, MODE_LOWER, =><5@_10@0_3);

            Buf_5[=><5@_10@0_3] = 0;

            Buf_0[0]=NULL;

            Print(" !!!!",  &/  " ",# DW D@0:B0;C, @8AC5< 2E>4 2 ,  Buf_2[0] = ",  Buf_2[0],

                  " Buf_0[0] = ",  Buf_0[0]);

           }



         else

            Print(" "  & ?> " ",# DW D@0:B0;C ");  //Buf_2[0]=0;}

     }

//-----------------------------------------------------------------------------------------------------------------------------------



// @0AG5B '" " $ " UP  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> '" " UP D@0:B0;C



   if(Buf_1[=><5@_10@0_0] > 0 && frac_0 > 0)

     {

      =><5@_10@0_4 = !!!",(_Symbol, 0, =><5@_10@0_3+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_4 > 0)

         if(Buf_1[=><5@_10@0_4] > 0  && Buf_1[=><5@_10@0_4] < Buf_1[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_4) > RSI_0 && RSI_0 !=0)

           {



            Buf_0[0]=Open[0]; // + 2*Point;  //  !# DW !" # 2E>40 2=87

            Buf_5[=><5@_10@0_4] = iFractals(_Symbol, 0, MODE_UPPER, =><5@_10@0_4);

            Buf_4[=><5@_10@0_4] = 0;

            Buf_2[0]=NULL;

            Print(" !!!!",  &/  '  "# UP D@0:B0;C, @8AC5< 2E>4 2 ! ,  Buf_0[0] = ",  Buf_0[0],

                  " Buf_2[0] = ",  Buf_2[0]);

           }



         else

            Print(" "  & ?> '  "# UP D@0:B0;C ");//Buf_0[0]=0;}

     }



// @0AG5B '" " $ " DW  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> '" " DW D@0:B0;C

   if(Buf_3[=><5@_10@0_0] > 0 && frac_0 < 0)

     {

      =><5@_10@0_4 = !!!",(_Symbol, 0, =><5@_10@0_3+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_4 > 0)

         if(Buf_3[=><5@_10@0_4] > 0  && Buf_3[=><5@_10@0_4] > Buf_3[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_4) <  RSI_0 && RSI_0 !=0)

           {



            Buf_2[0]=Open[0]; //- 2*Point;;  //  !# UP !" # 2E>40 UP

            Buf_4[=><5@_10@0_4] = iFractals(_Symbol, 0, MODE_LOWER, =><5@_10@0_4);

            Buf_5[=><5@_10@0_4] = 0;

            Buf_0[0]=NULL;

            Print(" !!!!",  &/  '  "# DW D@0:B0;C, @8AC5< 2E>4 2 ,  Buf_2[0] = ",  Buf_2[0],

                  " Buf_0[0] = ",  Buf_0[0]);

           }



         else

            Print(" "  & ?> '  "# DW D@0:B0;C ");  //Buf_2[0]=0;}

     }

//-----------------------------------------------------------------------------------------------------------------------------------





// @0AG5B /" $ " UP  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> /"# UP D@0:B0;C



   if(Buf_1[=><5@_10@0_0] > 0 && frac_0 > 0)

     {

      =><5@_10@0_5 = !!!",(_Symbol, 0, =><5@_10@0_4+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_5 > 0)

         if(Buf_1[=><5@_10@0_5] > 0  && Buf_1[=><5@_10@0_5] < Buf_1[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_5) > RSI_0 && RSI_0 !=0)

           {



            Buf_0[0]=Open[0]; // + 5*Point;  //  !# DW !" # 2E>40 2=87

            Buf_5[=><5@_10@0_5] = iFractals(_Symbol, 0, MODE_UPPER, =><5@_10@0_5);

            Buf_4[=><5@_10@0_5] = 0;

            Buf_2[0]=NULL;  // A1@0AK205< 1CD5@ OG59:8 =0;8G8O 4825@35=F88  DW D@0:B0;0

            Print(" !!!!",  &/  /"# UP D@0:B0;C, @8AC5< 2E>4 2 !,  Buf_0[0] = ",  Buf_0[0],

                  " Buf_2[0] = ",  Buf_2[0]);

           }



         else

            Print(" "  & ?> /"# UP D@0:B0;C ");//Buf_0[0]=0;}

     }



// @0AG5B /" $ " DW  RSI ! !" " !!!" (   ') 4;O @0AG5B0 4825@35=F88 ?> /" DW D@0:B0;C

   if(Buf_3[=><5@_10@0_0] > 0 && frac_0 < 0)

     {

      =><5@_10@0_5 = !!!",(_Symbol, 0, =><5@_10@0_4+1, frac_0);



      if(=><5@_10@0_0 > 0 && =><5@_10@0_5 > 0)

         if(Buf_3[=><5@_10@0_5] > 0  && Buf_3[=><5@_10@0_5] > Buf_3[=><5@_10@0_0] &&

            iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,=><5@_10@0_5) <  RSI_0 && RSI_0 !=0)

           {



            Buf_2[0]=Open[0]; //- 5*Point;;  //  !# UP !" # 2E>40 UP

            Buf_4[=><5@_10@0_5] = iFractals(_Symbol, 0, MODE_LOWER, =><5@_10@0_5);

            Buf_5[=><5@_10@0_5] = 0;

            Buf_0[0]=NULL;  // A1@0AK205< 1CD5@ OG59:8 =0;8G8O 4825@35=F88  UP D@0:B0;0

            Print(" !!!!",  &/  /"# DW D@0:B0;C, @8AC5< 2E>4 2 ,  Buf_2[0] = ",  Buf_2[0],

                  " Buf_0[0] = ",  Buf_0[0]);

           }



         else

            Print(" "  & ?> /"# DW D@0:B0;C ");  //Buf_2[0]=0;}

     }

//-----------------------------------------------------------------------------------------------------------------------------------







   return(0);

  }







//MathAbs

//iBarShift





//  )"       !!!"

int !!!",(string smb, int tf, int iB, double F)  // ?@>25@:0 A>>A=>AB8 B>G5: ?5@53810 >G5@54=>3> $ " 8 RSI

  {

   int =><5@_10@0 = 0,     // =><5@ 10@0 D@0:B0;0



   n=iBars(smb, tf);



   double

   fractal = 0;



   double RSICurrent,RSIPrevious, RSIPrevPrevious;

   double RSINext,RSINextNext;



   for(int i=iB; i<n; i++)               // F8:; A   ?>;CG5==>3> 10@0 23;C1L 8AB>@88 4;O ?@>25@:8 A>>A=>AB8

     {



      fractal = iFractals(smb, tf, MODE_UPPER, i);

      if(F > 0)                                       //  !'"  !%+ +   %% $ "

         if(fractal > 0 && =><5@_10@0 == 0)

           {

            =><5@_10@0 = i;

            Print(" '  D@0:B0; UP: ", fractal, " =0 10@5 ! ", =><5@_10@0," ?@>25@:0 =0;8G8O B>G5: ?5@5381>2 8 A>>A=>AB8... ");



            // =0;8G85 B>G5: ?5@53810 A RSI 8 A>>A=>ABL A iFractals

            RSICurrent =  iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);        // 10@K 3

            RSIPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);      // 4

            RSIPrevPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+2);  // 5

            RSINext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-1);          // 2

            RSINextNext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-2);      // 1



            if((RSICurrent > RSINext && RSICurrent > RSIPrevious) || (RSICurrent < RSIPrevious && RSIPrevious > RSIPrevPrevious) ||

               (RSICurrent < RSINext && RSINext > RSINextNext) || (RSICurrent > RSIPrevPrevious && RSICurrent > RSINext)         ||

               (RSIPrevPrevious < RSIPrevious && RSIPrevious > RSINext) || (RSICurrent > RSIPrevPrevious &&  RSICurrent > RSINextNext) ||

               (RSINext > RSIPrevious && RSINext > RSINextNext) || (RSIPrevPrevious < RSINext && RSINext > RSINextNext)          ||

               (RSICurrent > RSIPrevious && RSICurrent > RSINextNext))

              {

               Print(" ' B>G5: ?5@53810 RSI 8 A>>A=>AB8 A "#) (' +) UP - D@0:B0;>< ");

               Buf_1[=><5@_10@0] = fractal;



               // break;

               return(=><5@_10@0);

              }

            else

              {

               Print(" "!#"!" B>G5: ?5@53810 RSI 8 A>>A=>AB8 A "#) (' +) UP - D@0:B0;>< ");

               Buf_1[=><5@_10@0] = NULL;

               return(-=><5@_10@0);

              }

           }







      //  !'" '/  !!!"  $ "

      fractal = iFractals(smb, tf, MODE_LOWER, i);

      if(F < 0)                                       //  !'"  !%+ + % $ "

         if(fractal > 0 && =><5@_10@0 == 0)

           {

            =><5@_10@0 = i;

            Print(" '  D@0:B0; DW: ", fractal, " =0 10@5 ! ", =><5@_10@0, " ?@>25@:0 =0;8G8O B>G5: ?5@5381>2 8 A>>A=>AB8... ");



            // @0AG5B 7=0G5=89 8=4 RSI =0 =0;8G85 B>G5: ?5@53810 8 A>>A=>AB8 A iFractals

            RSICurrent =  iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i);        // 10@K 3

            RSIPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+1);      // 4

            RSIPrevPrevious = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i+2);  // 5

            RSINext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-1);          // 2

            RSINextNext = iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,i-2);      // 1



            if((RSICurrent < RSINext && RSICurrent < RSIPrevious) || (RSICurrent > RSIPrevious && RSIPrevious < RSIPrevPrevious) ||

               (RSICurrent > RSINext && RSINext < RSINextNext) || (RSICurrent < RSIPrevPrevious && RSICurrent < RSINext)         ||

               (RSIPrevPrevious > RSIPrevious && RSIPrevious < RSINext) || (RSICurrent < RSIPrevPrevious &&  RSICurrent < RSINextNext) ||

               (RSINext < RSIPrevious && RSINext < RSINextNext) || (RSIPrevPrevious > RSINext && RSINext < RSINextNext)          ||

               (RSICurrent < RSIPrevious && RSICurrent < RSINextNext))

              {

               Print(" ' B>G5: ?5@53810 RSI 8 A>>A=>AB8 A "#) (' +) DW - D@0:B0;>< ");

               Buf_3[=><5@_10@0]= fractal;

               //frac_0 = -frac_0;

               return(=><5@_10@0);

              }

            else

              {

               Print(" "!#"!" B>G5: ?5@53810 RSI 8 A>>A=>AB8 A "#) (' +) DW - D@0:B0;>< ");

               Buf_3[=><5@_10@0] = NULL;

               return(-=><5@_10@0);

              }

           }

     } // : for (int i=iB; i<n; i++)

   return(0);

  }



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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---