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

//|                                                       ColorSTLM.mq5 | 

//|                                  Copyright © 2013, Nikolay Kositsin | 

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

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

//| ;O @01>BK  8=48:0B>@0  A;54C5B  ?>;>68BL D09; SmoothAlgorithms.mqh |

//| 2 ?0?:C (48@5:B>@8N): :0B0;>3_40==KE_B5@<8=0;0\\MQL5\Include        |

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

//---- 02B>@AB2> 8=48:0B>@0

#property copyright "Copyright © 2013, Nikolay Kositsin"

//---- AAK;:0 =0 A09B 02B>@0

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

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

#property version   "1.00"

//---- >B@8A>2:0 8=48:0B>@0 2 >B45;L=>< >:=5

#property indicator_separate_window 

//---- :>;8G5AB2> 8=48:0B>@=KE 1CD5@>2

#property indicator_buffers 3 

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

#property indicator_plots   2

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

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

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

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

#property indicator_type1 DRAW_COLOR_HISTOGRAM

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

#property indicator_color1 clrRed,clrMagenta,clrGray,clrTeal,clrSpringGreen

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

#property indicator_style1 STYLE_SOLID

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

#property indicator_width1 2

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

#property indicator_label1 "STLM HISTOGRAM"

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

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

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

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

#property indicator_type2 DRAW_LINE

//---- 2 :0G5AB25 F25B0 A83=0;L=>9 ;8=88 8A?>;L7>20= A5@K9 F25B

#property indicator_color2 clrGray

//---- ;8=8O 8=48:0B>@0-HB@8E?C=:B8@=0O :@820O

#property indicator_style2 STYLE_DASHDOTDOT

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

#property indicator_width2 2

//---- >B>1@065=85 <5B:8 A83=0;L=>9 ;8=88

#property indicator_label2  "STLM"

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

//| 0@0<5B@K >B>1@065=8O 3>@87>=B0;L=KE C@>2=59 |

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

#property indicator_level1 0.0

#property indicator_levelcolor clrBlueViolet

#property indicator_levelstyle STYLE_SOLID

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

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

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

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

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

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

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

input int STLMShift=0; // !4283 STLM ?> 3>@87>=B0;8 2 10@0E

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

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

int STLMPeriod=91;

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

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

double IndBuffer[],ColorIndBuffer[],IndBuffer_[];

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

int min_rates_total;

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

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

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

#include <SmoothAlgorithms.mqh> 

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

//| Custom indicator initialization function                         |

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

void OnInit()

  {

//---- 8=8F80;870F8O ?5@5<5==KE =0G0;0 >BAG5B0 40==KE

   min_rates_total=STLMPeriod+1+30;

//---- ?@52@0I5=85 48=0<8G5A:8E <0AA82>2 2 8=48:0B>@=K5 1CD5@K

   SetIndexBuffer(0,IndBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,ColorIndBuffer,INDICATOR_COLOR_INDEX);

   SetIndexBuffer(2,IndBuffer_,INDICATOR_DATA);

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

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,STLMPeriod);

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

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);

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

   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,STLMPeriod);

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

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);

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

   string shortname="STLM";

//--- 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,1);

  }

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

//| 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 int begin,           // =><5@ =0G0;0 4>AB>25@=>3> >BAG5B0 10@>2

                const double &price[])     // F5=>2>9 <0AA82 4;O @0AG5B0 8=48:0B>@0

  {

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

   if(rates_total<min_rates_total+begin) return(0);

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

   int first,bar;

   double STLM,JSTLM,value1,value2,clr;

   static int minbar;

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

   static CJJMA JMA;

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

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

     {

      first=STLMPeriod-1+begin;  // AB0@B>2K9 =><5@ 4;O @0AG5B0 2A5E 10@>2

      minbar=first;

      //---- C25;8G8< ?>78F8N =0G0;0 40==KE =0 begin 10@>2, 2A;54AB285 @0AG5B>2 =0 40==KE 4@C3>3> 8=48:0B>@0

      if(begin>0)

        {

         PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,begin+min_rates_total);

         PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,begin+min_rates_total);

        }

     }

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

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

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

     {

      value1=

             +0.0982862174*price[bar-0]

             +0.0975682269*price[bar-1]

             +0.0961401078*price[bar-2]

             +0.0940230544*price[bar-3]

             +0.0912437090*price[bar-4]

             +0.0878391006*price[bar-5]

             +0.0838544303*price[bar-6]

             +0.0793406350*price[bar-7]

             +0.0743569346*price[bar-8]

             +0.0689666682*price[bar-9]

             +0.0632381578*price[bar-10]

             +0.0572428925*price[bar-11]

             +0.0510534242*price[bar-12]

             +0.0447468229*price[bar-13]

             +0.0383959950*price[bar-14]

             +0.0320735368*price[bar-15]

             +0.0258537721*price[bar-16]

             +0.0198005183*price[bar-17]

             +0.0139807863*price[bar-18]

             +0.0084512448*price[bar-19]

             +0.0032639979*price[bar-20]

             -0.0015350359*price[bar-21]

             -0.0059060082*price[bar-22]

             -0.0098190256*price[bar-23]

             -0.0132507215*price[bar-24]

             -0.0161875265*price[bar-25]

             -0.0186164872*price[bar-26]

             -0.0205446727*price[bar-27]

             -0.0219739146*price[bar-28]

             -0.0229204861*price[bar-29]

             -0.0234080863*price[bar-30]

             -0.0234566315*price[bar-31]

             -0.0231017777*price[bar-32]

             -0.0223796900*price[bar-33]

             -0.0213300463*price[bar-34]

             -0.0199924534*price[bar-35]

             -0.0184126992*price[bar-36]

             -0.0166377699*price[bar-37]

             -0.0147139428*price[bar-38]

             -0.0126796776*price[bar-39]

             -0.0105938331*price[bar-40]

             -0.0084736770*price[bar-41]

             -0.0063841850*price[bar-42]

             -0.0043466731*price[bar-43]

             -0.0023956944*price[bar-44]

             -0.0005535180*price[bar-45]

             +0.0011421469*price[bar-46]

             +0.0026845693*price[bar-47]

             +0.0040471369*price[bar-48]

             +0.0052380201*price[bar-49]

             +0.0062194591*price[bar-50]

             +0.0070340085*price[bar-51]

             +0.0076266453*price[bar-52]

             +0.0080376628*price[bar-53]

             +0.0083037666*price[bar-54]

             +0.0083694798*price[bar-55]

             +0.0082901022*price[bar-56]

             +0.0080741359*price[bar-57]

             +0.0077543820*price[bar-58]

             +0.0073260526*price[bar-59]

             +0.0068163569*price[bar-60]

             +0.0062325477*price[bar-61]

             +0.0056078229*price[bar-62]

             +0.0049516078*price[bar-63]

             +0.0161380976*price[bar-64];

      //----

      value2=

             -0.0074151919*price[bar-0]

             -0.0060698985*price[bar-1]

             -0.0044979052*price[bar-2]

             -0.0027054278*price[bar-3]

             -0.0007031702*price[bar-4]

             +0.0014951741*price[bar-5]

             +0.0038713513*price[bar-6]

             +0.0064043271*price[bar-7]

             +0.0090702334*price[bar-8]

             +0.0118431116*price[bar-9]

             +0.0146922652*price[bar-10]

             +0.0175884606*price[bar-11]

             +0.0204976517*price[bar-12]

             +0.0233865835*price[bar-13]

             +0.0262218588*price[bar-14]

             +0.0289681736*price[bar-15]

             +0.0315922931*price[bar-16]

             +0.0340614696*price[bar-17]

             +0.0363444061*price[bar-18]

             +0.0384120882*price[bar-19]

             +0.0402373884*price[bar-20]

             +0.0417969735*price[bar-21]

             +0.0430701377*price[bar-22]

             +0.0440399188*price[bar-23]

             +0.0446941124*price[bar-24]

             +0.0450230100*price[bar-25]

             +0.0450230100*price[bar-26]

             +0.0446941124*price[bar-27]

             +0.0440399188*price[bar-28]

             +0.0430701377*price[bar-29]

             +0.0417969735*price[bar-30]

             +0.0402373884*price[bar-31]

             +0.0384120882*price[bar-32]

             +0.0363444061*price[bar-33]

             +0.0340614696*price[bar-34]

             +0.0315922931*price[bar-35]

             +0.0289681736*price[bar-36]

             +0.0262218588*price[bar-37]

             +0.0233865835*price[bar-38]

             +0.0204976517*price[bar-39]

             +0.0175884606*price[bar-40]

             +0.0146922652*price[bar-41]

             +0.0118431116*price[bar-42]

             +0.0090702334*price[bar-43]

             +0.0064043271*price[bar-44]

             +0.0038713513*price[bar-45]

             +0.0014951741*price[bar-46]

             -0.0007031702*price[bar-47]

             -0.0027054278*price[bar-48]

             -0.0044979052*price[bar-49]

             -0.0060698985*price[bar-50]

             -0.0074151919*price[bar-51]

             -0.0085278517*price[bar-52]

             -0.0094111161*price[bar-53]

             -0.0100658241*price[bar-54]

             -0.0104994302*price[bar-55]

             -0.0107227904*price[bar-56]

             -0.0107450280*price[bar-57]

             -0.0105824763*price[bar-58]

             -0.0102517019*price[bar-59]

             -0.0097708805*price[bar-60]

             -0.0091581551*price[bar-61]

             -0.0084345004*price[bar-62]

             -0.0076214397*price[bar-63]

             -0.0067401718*price[bar-64]

             -0.0058083144*price[bar-65]

             -0.0048528295*price[bar-66]

             -0.0038816271*price[bar-67]

             -0.0029244713*price[bar-68]

             -0.0019911267*price[bar-69]

             -0.0010974211*price[bar-70]

             -0.0002535559*price[bar-71]

             +0.0005231953*price[bar-72]

             +0.0012297491*price[bar-73]

             +0.0018539149*price[bar-74]

             +0.0023994354*price[bar-75]

             +0.0028490136*price[bar-76]

             +0.0032221429*price[bar-77]

             +0.0034936183*price[bar-78]

             +0.0036818974*price[bar-79]

             +0.0038037944*price[bar-80]

             +0.0038338964*price[bar-81]

             +0.0037975350*price[bar-82]

             +0.0036986051*price[bar-83]

             +0.0035521320*price[bar-84]

             +0.0033559226*price[bar-85]

             +0.0031224409*price[bar-86]

             +0.0028550092*price[bar-87]

             +0.0025688349*price[bar-88]

             +0.0022682355*price[bar-89]

             +0.0073925495*price[bar-90];

      //---

      STLM=value1-value2;

      JSTLM=JMA.JJMASeries(minbar,prev_calculated,rates_total,0,JPhase,JLength,STLM,bar,false);

      //---- 8=8F80;870F8O OG59:8 8=48:0B>@=>3> 1CD5@0 ?>;CG5==K< 7=0G5=85< FTLM

      IndBuffer[bar]=JSTLM;

      IndBuffer_[bar]=JSTLM;

     }

//---

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

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

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

     {

      clr=2;

      //---

      if(IndBuffer[bar]>0) if(IndBuffer[bar-1]>IndBuffer[bar]) clr=3; else clr=4;

      if(IndBuffer[bar]<0) if(IndBuffer[bar-1]<IndBuffer[bar]) clr=1; else clr=0;

      //---

      ColorIndBuffer[bar]=clr;

     }

//----     

   return(rates_total);

  }

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

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