JSatl_Digit_System

Author: Copyright © 2016, Nikolay Kositsin
2 Views
0 Downloads
0 Favorites
JSatl_Digit_System
ÿþ//+------------------------------------------------------------------+

//|                                           JSatl_Digit_System.mq5 |

//|                               Copyright © 2016, Nikolay Kositsin | 

//|                              Khabarovsk,   farria@mail.redcom.ru | 

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

#property copyright "Copyright © 2016, Nikolay Kositsin"

#property link "farria@mail.redcom.ru"

#property description "@>1>9=0O A8AB5<0 A 8A?>;L7>20=85< 8=48:0B>@0 JSatl_Digit"

//---- =><5@ 25@A88 8=48:0B>@0

#property version   "1.00"

//---- >B@8A>2:0 8=48:0B>@0 2 3;02=>< >:=5

#property indicator_chart_window

//---- 4;O @0AGQB0 8 >B@8A>2:8 8=48:0B>@0 8A?>;L7>20=> A5<L 1CD5@>2

#property indicator_buffers 7

//---- 8A?>;L7>20=> G5BK@5 3@0D8G5A:8E ?>AB@>5=8O

#property indicator_plots   4

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

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 1            |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >4=>F25B=>3> >1;0:0

#property indicator_type1   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 8=48:0B>@0 8A?>;L7>20= WhiteSmoke F25B

#property indicator_color1  clrWhiteSmoke

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label1  "JSatl_Digit"

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

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 2            |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2 2845 ;8=88

#property indicator_type2   DRAW_LINE

//---- 2 :0G5AB25 F25B0 1KG59 ;8=88 8=48:0B>@0 8A?>;L7>20= MediumSeaGreen F25B

#property indicator_color2  clrMediumSeaGreen

//---- ;8=8O 8=48:0B>@0 2 - =5?@5@K2=0O :@820O

#property indicator_style2  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 2 @02=0 2

#property indicator_width2  2

//---- >B>1@065=85 1KG59 <5B:8 8=48:0B>@0

#property indicator_label2  "Upper JSatl_Digit"

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

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 3            |

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

//---- >B@8A>2:0 8=48:0B>@0 3 2 2845 ;8=88

#property indicator_type3   DRAW_LINE

//---- 2 :0G5AB25 F25B0 <54256L59 ;8=88 8=48:0B>@0 8A?>;L7>20= Magenta F25B

#property indicator_color3  clrMagenta

//---- ;8=8O 8=48:0B>@0 3 - =5?@5@K2=0O :@820O

#property indicator_style3  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 3 @02=0 2

#property indicator_width3  2

//---- >B>1@065=85 <54256L59 <5B:8 8=48:0B>@0

#property indicator_label3  "Lower JSatl_Digit"

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

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 4            |

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

//---- >B@8A>2:0 8=48:0B>@0 2 2845 G5BK@QEF25B=>9 38AB>3@0<<K

#property indicator_type4 DRAW_COLOR_HISTOGRAM2

//---- 2 :0G5AB25 F25B>2 G5BK@QEF25B=>9 38AB>3@0<<K 8A?>;L7>20=K

#property indicator_color4 clrRed,clrPurple,clrGray,clrSeaGreen,clrChartreuse

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style4 STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 2

#property indicator_width4 2

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label4 "JSatl_Digit_BARS"

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

//|  ?8A0=85 :;0AA0 CXMA             |

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

#include <SmoothAlgorithms.mqh> 

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

//---- >1JO2;5=85 ?5@5<5==>9 :;0AA0 CJJMA 87 D09;0 JJMASeries_Cls.mqh

CJJMA HJMA,LJMA;

//---- >1JO2;5=85 ?5@5<5==>9 :;0AA0 CSATL 87 D09;0 JJMASeries_Cls.mqh

CSATL HSTL,LSTL; 

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

//| E>4=K5 ?0@0<5B@K 8=48:0B>@0                 |

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

input string  SirName="ColorJSatl_Digit";     // ?5@20O G0ABL 8<5=8 3@0D8G5A:8E >1J5:B>2

input int JLength=5;                          // 3;C18=0 JMA A3;06820=8O                   

input int JPhase=-100;                        // ?0@0<5B@ JMA A3;06820=8O,

//---- 87<5=ONI89AO 2 ?@545;0E -100 ... +100,

//---- 2;8O5B =0 :0G5AB2> ?5@5E>4=>3> ?@>F5AA0;

input int PriceShift=0;                       // c4283 :0=0;0 ?> 25@B8:0;8 2 ?C=:B0E

input uint   Shift=2;                         // A4283 :0=0;0 ?> 3>@87>=B0;8 2 10@0E 

input uint Digit=2;                           // :>;8G5AB2> @07@O4>2 >:@C3;5=8O

input bool ShowPrice=true;                    // ?>:07K20BL F5=>2K5 <5B:8

//---- F25B0 F5=>2KE <5B>:

input color  Up_Price_color=clrTeal;

input color  Dn_Price_color=clrMagenta;

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

//---- >1JO2;5=85 48=0<8G5A:8E <0AA82>2, :>B>@K5 1C4CB 2 

// 40;L=59H5< 8A?>;L7>20=K 2 :0G5AB25 8=48:0B>@=KE 1CD5@>2

double Up1Buffer[],Dn1Buffer[];

double Up2Buffer[],Dn2Buffer[];

double UpIndBuffer[],DnIndBuffer[],ColorIndBuffer[];

//---- 1JO2;5=85 F5;KE ?5@5<5==KE =0G0;0 >BAGQB0 40==KE

int min_rates_total;

//---- >1JO2;5=85 8 8=8F80;870F8O ?5@5<5==>9 4;O E@0=5=8O :>;8G5AB20 @0AGQB=KE 10@>2

int SATLPeriod=65;

double dPriceShift;

double PointPow10;

//---- 1JO2;5=85 AB@8=3>2 4;O B5:AB>2KE <5B>:

string Dn_Price_name,Up_Price_name;

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

//| Custom indicator initialization function                         |

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

void OnInit()

  {

//---- 8=8F80;870F8O ?5@5<5==KE 

   min_rates_total=SATLPeriod+30+int(Shift);

//---- =8F80;870F8O A42830 ?> 25@B8:0;8

   dPriceShift=_Point*PriceShift;

   PointPow10=_Point*MathPow(10,Digit);

//---- =8F80;870F8O AB@8=3>2

   Up_Price_name=SirName+"Up_Price";

   Dn_Price_name=SirName+"Dn_Price";



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(0,Up1Buffer,INDICATOR_DATA);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(1,Dn1Buffer,INDICATOR_DATA);

   

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(2,Up2Buffer,INDICATOR_DATA);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(3,Dn2Buffer,INDICATOR_DATA);

   

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 IndBuffer 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(4,UpIndBuffer,INDICATOR_DATA);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 IndBuffer 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(5,DnIndBuffer,INDICATOR_DATA);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 F25B>2>9, 8=45:A=K9 1CD5@   

   SetIndexBuffer(6,ColorIndBuffer,INDICATOR_COLOR_INDEX);



   

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 1 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(0,PLOT_SHIFT,Shift);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0 1 =0 min_rates_total

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);

   

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 2 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(1,PLOT_SHIFT,Shift);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0 2 =0 min_rates_total

   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);

   

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 3 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(2,PLOT_SHIFT,Shift);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0 3 =0 min_rates_total

   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);

   

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 3 ?> 3>@87>=B0;8 =0 Shift

   PlotIndexSetInteger(3,PLOT_SHIFT,0);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0 4 =0 min_rates_total

   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0);



//---- 8=8F80;870F88 ?5@5<5==>9 4;O :>@>B:>3> 8<5=8 8=48:0B>@0

   string shortname;

   StringConcatenate(shortname,"JSatl_Digit_System(",Shift,")");

//--- A>740=85 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5

   IndicatorSetString(INDICATOR_SHORTNAME,shortname);

//--- >?@545;5=85 B>G=>AB8 >B>1@065=8O 7=0G5=89 8=48:0B>@0

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

//----

  }

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

//| Custom indicator deinitialization function                       |

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

void OnDeinit(const int reason)

  {

//----

   ObjectDelete(0,Up_Price_name);

   ObjectDelete(0,Dn_Price_name);

//----

   ChartRedraw(0);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(

                const int rates_total,    // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5

                const int prev_calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[]

                )

  {

//---- ?@>25@:0 :>;8G5AB20 10@>2 =0 4>AB0B>G=>ABL 4;O @0AGQB0

   if(rates_total<min_rates_total) return(0);



//---- >1JO2;5=8O ;>:0;L=KE ?5@5<5==KE 

   int first,bar;

   double jsatl,SATL;

   static int fstart;



//---- @0AGQB AB0@B>2>3> =><5@0 first 4;O F8:;0 ?5@5AGQB0 10@>2

   if(prev_calculated>rates_total || prev_calculated<=0) // ?@>25@:0 =0 ?5@2K9 AB0@B @0AGQB0 8=48:0B>@0

     {

      first=0; // AB0@B>2K9 =><5@ 4;O @0AGQB0 2A5E 10@>2

      fstart=SATLPeriod;

     }

   else first=prev_calculated-1; // AB0@B>2K9 =><5@ 4;O @0AGQB0 =>2KE 10@>2



//---- >A=>2=>9 F8:; @0AGQB0 8=48:0B>@0

   for(bar=first; bar<rates_total && !IsStopped(); bar++)

     {

      //---- AB@>8< 25@E=NN 3@0=8FC :0=0;0

      SATL=HSTL.SATLSeries(0,prev_calculated,rates_total,high[bar],bar,false);

      jsatl=HJMA.JJMASeries(fstart,prev_calculated,rates_total,0,JPhase,JLength,SATL,bar,false);

      jsatl+=dPriceShift;      

      Up1Buffer[bar]=Up2Buffer[bar]=PointPow10*MathRound(jsatl/PointPow10);

      //---- AB@>8< =86=NN 3@0=8FC :0=0;0

      SATL=LSTL.SATLSeries(0,prev_calculated,rates_total,low[bar],bar,false);

      jsatl=LJMA.JJMASeries(fstart,prev_calculated,rates_total,0,JPhase,JLength,SATL,bar,false);

      jsatl+=dPriceShift;

      Dn1Buffer[bar]=Dn2Buffer[bar]=PointPow10*MathRound(jsatl/PointPow10);

     }





//---- @0AGQB AB0@B>2>3> =><5@0 first 4;O F8:;0 ?5@5AGQB0 10@>2

   if(prev_calculated>rates_total || prev_calculated<=0) first=min_rates_total;     

//---- A=>2=>9 F8:; @0A:@0A:8 10@>2 8=48:0B>@0

   for(bar=first; bar<rates_total && !IsStopped(); bar++)

     {

      int clr=2;

      UpIndBuffer[bar]=0.0;

      DnIndBuffer[bar]=0.0;

      

      if(close[bar]>Up1Buffer[bar-Shift])

        {

         if(open[bar]<close[bar]) clr=4;

         else clr=3;

         UpIndBuffer[bar]=high[bar];

         DnIndBuffer[bar]=low[bar];

        }



      if(close[bar]<Dn1Buffer[bar-Shift])

        {

         if(open[bar]>close[bar]) clr=0;

         else clr=1;

         UpIndBuffer[bar]=high[bar];

         DnIndBuffer[bar]=low[bar];

        }



      ColorIndBuffer[bar]=clr;

     }

   if(ShowPrice)

     {

      int bar0=rates_total-1;

      datetime time0=time[bar0]+Shift*PeriodSeconds();

      SetRightPrice(0,Up_Price_name,0,time0,Up1Buffer[bar0-Shift],Up_Price_color);

      SetRightPrice(0,Dn_Price_name,0,time0,Dn1Buffer[bar0-Shift],Dn_Price_color);

     }

//----     

   ChartRedraw(0);

   return(rates_total);

  }

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

//|  RightPrice creation                                             |

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

void CreateRightPrice(long chart_id,// chart ID

                      string   name,              // object name

                      int      nwin,              // window index

                      datetime time,              // price level time

                      double   price,             // price level

                      color    Color              // Text color

                      )

//---- 

  {

//----

   ObjectCreate(chart_id,name,OBJ_ARROW_RIGHT_PRICE,nwin,time,price);

   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color);

   ObjectSetInteger(chart_id,name,OBJPROP_BACK,true);

   ObjectSetInteger(chart_id,name,OBJPROP_WIDTH,2);

//----

  }

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

//|  RightPrice reinstallation                                       |

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

void SetRightPrice(long chart_id,// chart ID

                   string   name,              // object name

                   int      nwin,              // window index

                   datetime time,              // price level time

                   double   price,             // price level

                   color    Color              // Text color

                   )

//---- 

  {

//----

   if(ObjectFind(chart_id,name)==-1) CreateRightPrice(chart_id,name,nwin,time,price,Color);

   else ObjectMove(chart_id,name,0,time,price);

//----

  }

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

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