BS_On_A_Wave

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each bar
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
BS_On_A_Wave
//*****************************************************************************//
//*****************************************************************************//
//*                                                          BS_On A Wave.mq4 *//
//*                                               Copyright © 2013, Backspace *//
//*                                                           Success Version *//
//*****************************************************************************//
//*****************************************************************************//
//*                             Òîðãóé òðåíäû                                 *//
//*                            Óìåíüøàé ïîòåðè                                *//
//*                          Äàâàé ïðèáûëè ðàñòè                              *//
//*                            Óïðàâëÿé ðèñêàìè                               *//
//*****************************************************************************//
//*****************************************************************************//
#property copyright "Copyright © 2013, Backspace"                              //
#property link      "Success Version"                                          //
                                                                               //
#property indicator_chart_window                                               //
#property indicator_buffers 6                                                  //
#property indicator_color1 Yellow                                              //
#property indicator_color2 Red                                                 //
#property indicator_color3 Yellow                                              //
#property indicator_color4 Red                                                 //
#property indicator_color5 Snow                                                //
#property indicator_color6 Snow                                                //
                                                           //******************// Ââîä ïàðàìåòðîâ èíäèêàòîðà
extern int    BarQuant =24;                                                    //   - êîë-âî ïðîñ÷èòûâàåìûõ áàðîâ
                                                           //******************// Ñîñòàâíûå ÷àñòè èíäèêàòîðà
double        ExtrimHi[],                                                      //   - ýêñòðåìóì High
              ExtrimLo[],                                                      //   - ýêñòðåìóì Low
              BreakHi[],                                                       //   - ýêñòðåìóì High
              BreakLo[],                                                       //   - ýêñòðåìóì Low
              HiMA[],                                                          //
              LoMA[];                                                          //
                                                           //******************// Ãëîáàëüíûå ïåðåìåííûå
int           Trend;                                                           //
datetime      CurrTime,                                                        //   - òåêóùåå âðåìÿ
              LastTime;                                                        //   - âðåìÿ îòêðûòèÿ ïîñëåäíåãî áàðà
                                                                               //
//*****************************************************************************//
//**************************-Indicator Initialization-*************************//
//*****************************************************************************//
                                                                               //
int init()                                                                     //
  {                                                                            //
                                                           //******************// Íàñòðîéêè ãðàôè÷åñêîãî îòîáðàæåíèÿ
   IndicatorBuffers   (6);                                                     //
   SetIndexLabel      (0,"ExtrimHi");                                          //
   SetIndexBuffer     (0,ExtrimHi);                                            //
   SetIndexStyle      (0,DRAW_ARROW,EMPTY,4);                                  //
   SetIndexArrow      (0,159);                                                 //
   SetIndexLabel      (1,"ExtrimLo");                                          //
   SetIndexBuffer     (1,ExtrimLo);                                            //
   SetIndexStyle      (1,DRAW_ARROW,EMPTY,4);                                  //
   SetIndexArrow      (1,159);                                                 //
   SetIndexLabel      (2,"HiMA");                                              //
   SetIndexBuffer     (2,HiMA);                                                //
   SetIndexStyle      (2,DRAW_LINE,EMPTY,1);                                   //
   SetIndexLabel      (3,"LoMA");                                              //
   SetIndexBuffer     (3,LoMA);                                                //
   SetIndexStyle      (3,DRAW_LINE,EMPTY,1);                                   //
   SetIndexLabel      (4,"BreakHi");                                           //
   SetIndexBuffer     (4,BreakHi);                                             //
   SetIndexStyle      (4,DRAW_HISTOGRAM,EMPTY,5);                              //
   SetIndexArrow      (4,159);                                                 //
   SetIndexLabel      (5,"BreakLo");                                           //
   SetIndexBuffer     (5,BreakLo);                                             //
   SetIndexStyle      (5,DRAW_HISTOGRAM,EMPTY,5);                              //
   SetIndexArrow      (5,159);                                                 //
                                                                    //*********//
   return(0);                                                                  //
  }                                                                            //
                                                                               //
//*****************************************************************************//
//*************************-Indicator Deinitialization-************************//
//*****************************************************************************//
                                                                               //
int deinit()                                                                   //
  {                                                                            //
   Comment("");                                                                //
                                                                    //*********//
   return(0);                                                                  //
  }                                                                            //
                                                                               //
//*****************************************************************************//
//**********************************-On A Wave-********************************//
//*****************************************************************************//
                                                                               //
int start()                                                                    //
  {                                                                            //
   for(int s=Bars-1-IndicatorCounted(); s>=0; s--)                             //
     {                                                                         //
      Comment("On A Wave\n","Spread =",MarketInfo(Symbol(),MODE_SPREAD));      //
      Extrim_Detect(s);                                    //******************// Îïðåäåëåíèå ýêñòðåìóìîâ
     }                                                                         //
                                                                    //*********//
   return(0);                                                                  //
  }                                                                            //
                                                                               //
//*****************************************************************************//
//*********************************-SubPogramms-*******************************//
//*****************************************************************************//
                                                                               //
double Extrim_Detect(int a)               //***********************************// Îïðåäåëåíèå ýêñòðåìóìîâ
  {                                                                            //
   LastTime =iTime(NULL,0,a);                                                  //
   HiMA[a]  =iMA(NULL,0,BarQuant,1,3,2,a);                                     //
   LoMA[a]  =iMA(NULL,0,BarQuant,1,3,3,a);                                     //
   if((TimeDayOfWeek(Time[a])==5 && TimeHour(Time[a])>=20)||                   //
      (TimeDayOfWeek(Time[a])==1 && TimeHour(Time[a])<1))                      //
     {Trend =0; BreakHi[a] =iHigh(NULL,0,a); BreakLo[a] =iLow(NULL,0,a);}      //
   else if(CurrTime!=LastTime)                                                 //
     {                                                                         //
      if(Trend!=1 && iHigh(NULL,0,a)>HiMA[a] && iLow(NULL,0,a)<HiMA[a] &&      //
         iOpen(NULL,0,a)<HiMA[a])                                              //
        {ExtrimHi[a] =HiMA[a]; Trend =1; CurrTime=LastTime;}                   //
      else if(Trend!=1 &&                                                      //
            ((iOpen(NULL,0,a)>HiMA[a] && iHigh(NULL,0,a+1)<HiMA[a+1])||        //
             (ExtrimLo[a+1]!=EMPTY_VALUE && iClose(NULL,0,a+1)>HiMA[a+1])))    //
        {ExtrimHi[a] =iOpen(NULL,0,a); Trend =1; CurrTime=LastTime;}           //
      else if(Trend!=-1 &&                                                     //
              iLow(NULL,0,a)<LoMA[a] && iHigh(NULL,0,a)>LoMA[a] &&             //
              iOpen(NULL,0,a)>LoMA[a])                                         //
        {ExtrimLo[a] =LoMA[a]; Trend =-1; CurrTime=LastTime;}                  //
      else if(Trend!=-1 &&                                                     //
            ((iOpen(NULL,0,a)<LoMA[a] && iLow(NULL,0,a+1)>LoMA[a+1])||         //
             (ExtrimHi[a+1]!=EMPTY_VALUE && iClose(NULL,0,a+1)<LoMA[a+1])))    //
        {ExtrimLo[a] =iOpen(NULL,0,a); Trend =-1; CurrTime=LastTime;}          //
     }                                                                         //
                                                                    //*********//
   return(0);                                                                  //
  }                                                                            //
                                                                               //
//*****************************************************************************//
//**************************************************************************BS*//
//*****************************************************************************//

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 ---