2 Äëÿ ðàáîòû èíäèêàòîðà ñëåäóåò ïîëîæèòü ôàéëû
\r
5 â ïàïêó (äèðåêòîðèþ): MetaTrader\experts\include\
\r
7 â ïàïêó (äèðåêòîðèþ): MetaTrader\indicators\
\r
9 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
11 //| JMA code: Copyright © 2005, Weld, Jurik Research |
\r
12 //| http://weld.torguem.net |
\r
13 //| MQL4+J2JMA: Copyright © 2006, Nikolay Kositsin |
\r
14 //| Khabarovsk, farria@mail.redcom.ru |
\r
15 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
16 #property copyright "Nikolay Kositsin"
\r
17 #property link "farria@mail.redcom.ru"
\r
18 //---- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
\r
19 #property indicator_chart_window
\r
20 //---- êîëè÷åñòâî èíäèêàòîðíûõ áóôôåðîâ
\r
21 #property indicator_buffers 1
\r
22 //---- öâåò èíäèêàòîðà
\r
23 #property indicator_color1 Magenta
\r
24 //---- ÂÕÎÄÍÛÅ ÏÀÐÀÌÅÒÐÛ ÈÍÄÈÊÀÒÎÐÀ þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþææ+
\r
25 extern int Length1 = 5; // ãëóáèíà ïåðâîãî ñãëàæèâàíèÿ
\r
26 extern int Length2 = 5; // ãëóáèíà âòîðîãî ñãëàæèâàíèÿ
\r
27 extern int Phase1 = 5; // ïàðàìåòð ïåðâîãî ñãëàæèâàíèÿ, èçìåíÿþùèéñÿ â ïðåäåëàõ -100 ... +100, âëèÿåò íà êà÷åñòâî ïåðåõîäíîãî ïðîöåññà;
\r
28 extern int Phase2 = 5; // ïàðàìåòð âòîðîãî ñãëàæèâàíèÿ, èçìåíÿþùèéñÿ â ïðåäåëàõ -100 ... +100, âëèÿåò íà êà÷åñòâî ïåðåõîäíîãî ïðîöåññà;
\r
29 extern int Shift = 0; // cäâèã èíäèêàòîðà âäîëü îñè âðåìåíè
\r
30 extern int Input_Price_Customs = 0;//Âûáîð öåí, ïî êîòîðûì ïðîèçâîäèòñÿ ðàñ÷¸ò èíäèêàòîðà
\r
31 //(0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 6-WEIGHTED, 7-Heiken Ashi Close, 8-SIMPL, 9-TRENDFOLLOW, 10-0.5*TRENDFOLLOW,
\r
32 //11-Heiken Ashi Low, 12-Heiken Ashi High, 13-Heiken Ashi Open, 14-Heiken Ashi Close.)
\r
33 //---- æææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ+
\r
34 //---- èíäèêàòîðíûå áóôôåðû
\r
36 //---- ïåðåìåííûå ñ ïëàâàþùåé òî÷êîé
\r
38 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
39 //| J2JMA indicator initialization function |
\r
40 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
43 //---- îïðåäåëåíèå ñòèëÿ èñïîëíåíèÿ ãðàôèêà
\r
44 SetIndexStyle (0,DRAW_LINE);
\r
45 //---- 1 èíäèêàòîðíûé áóôôåð èñïîëüçîâàí äëÿ ñ÷¸òà
\r
46 SetIndexBuffer(0,J2JMA);
\r
47 //---- ãîðèçîíòàëüíûé ñäâèã èíäèêàòîðíîé ëèíèè
\r
48 SetIndexShift (0, Shift);
\r
49 //---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
\r
50 SetIndexEmptyValue(0,0);
\r
51 //---- èìÿ äëÿ îêîí äàííûõ è ëýéáà äëÿ ñóáúîêîí.
\r
52 IndicatorShortName ("J2JMA( Length1="+Length1+", Phase1="+Phase1+", Length2="+Length2+", Phase2="+Phase2+", Shift="+Shift+")");
\r
53 SetIndexLabel (0, "J2JMA");
\r
55 IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
\r
56 //---- óñòàíîâêà àëåðòîâ íà íåäîïóñòèìûå çíà÷åíèÿ âõîäíûõ ïàðàìåòðîâ =================================================================+
\r
57 if(Phase1<-100){Alert("Ïàðàìåòð Phase1 äîëæåí áûòü îò -100 äî +100" + " Âû ââåëè íåäîïóñòèìîå " +Phase1+ " áóäåò èñïîëüçîâàíî -100");}
\r
58 if(Phase1> 100){Alert("Ïàðàìåòð Phase1 äîëæåí áûòü îò -100 äî +100" + " Âû ââåëè íåäîïóñòèìîå " +Phase1+ " áóäåò èñïîëüçîâàíî 100");}
\r
59 if(Phase2<-100){Alert("Ïàðàìåòð Phase2 äîëæåí áûòü îò -100 äî +100" + " Âû ââåëè íåäîïóñòèìîå " +Phase2+ " áóäåò èñïîëüçîâàíî -100");}
\r
60 if(Phase2> 100){Alert("Ïàðàìåòð Phase2 äîëæåí áûòü îò -100 äî +100" + " Âû ââåëè íåäîïóñòèìîå " +Phase2+ " áóäåò èñïîëüçîâàíî 100");}
\r
61 if(Length1< 1){Alert("Ïàðàìåòð Length1 äîëæåí áûòü íå ìåíåå 1" + " Âû ââåëè íåäîïóñòèìîå " +Length1+ " áóäåò èñïîëüçîâàíî 1" );}
\r
62 if(Length2< 1){Alert("Ïàðàìåòð Length2 äîëæåí áûòü íå ìåíåå 1" + " Âû ââåëè íåäîïóñòèìîå " +Length2+ " áóäåò èñïîëüçîâàíî 1" );}
\r
63 PriceSeriesAlert(Input_Price_Customs);
\r
64 //+===================================================================================================================================+
\r
65 //---- çàâåðøåíèå èíèöèàëèçàöèè
\r
68 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
69 //| J2JMA iteration function |
\r
70 //+SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS+
\r
73 //----+ Ââåäåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ
\r
74 //---- áëîêèðîâàíèå ïåðåñ÷¸òà âñåõ ïîäñ÷èòàííûõ è îòðèñîâàííûõ áàðîâ ïðè ïîäêëþ÷åíèè ê èíòåðíåòó
\r
75 int reset,MaxBar1,MaxBar2,counted_bars=INDICATOR_COUNTED(0); INDICATOR_COUNTED(1);
\r
76 //---- ïðîâåðêà íà âîçìîæíûå îøèáêè
\r
77 if (counted_bars<0){INDICATOR_COUNTED(-1);return(-1);}
\r
78 //---- ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí
\r
79 //---- (áåç ýòîãî ïåðåñ÷¸òà äëÿ counted_bars ôóíêöèÿ JJMASeries áóäåò ðàáîòàòü íåêîððåêòíî!!!)
\r
80 if (counted_bars>0) counted_bars--;
\r
81 //----+ Ââåäåíèå è èíèöèàëèçàöèÿ âíóòðåííèõ ïåðåìåííûõ ôóíêöèè JJMASeries, nJMAnumber=2(Äâà îáðàùåíèÿ ê ôóíêöèè JJMASeries)
\r
82 if (counted_bars==0)JJMASeriesReset(2);
\r
83 //---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò íîâûõ áàðîâ
\r
84 int limit=Bars-counted_bars-1; MaxBar1=Bars-1; MaxBar2=MaxBar1-30;
\r
86 //----+ ÎÑÍÎÂÍÎÉ ÖÈÊË ÂÛ×ÈÑËÅÍÈß ÈÍÄÈÊÀÒÎÐÀ
\r
87 for(int bar=limit;bar>=0;bar--)
\r
89 //----+ Îáðàùåíèå ê ôóíêöèè PriceSeries äëÿ ïîëó÷åíèÿ âõîäíîé öåíû Series
\r
90 Temp_Series=PriceSeries(Input_Price_Customs, bar);
\r
91 //+----------------------------------------------------------------------------+
\r
92 //----+ Äâà îáðàùåíèÿ ê ôóíêöèè JJMASeries çà íîìåðàìè 0, 1. Ïàðàìåòðû nJMAPhase è nJMALength íå ìåíÿþòñÿ íà êàæäîì áàðå (nJMAdin=0)
\r
93 //(Âî âòîðîì îáðàùåíèè ïàðàìåòð nJMAMaxBar óìåíüøåí íà 30 ò. ê. ýòî ïîâòîðíîå JMA ñãëàæèâàíèå)
\r
94 //+----------------------------------------------------------------------------+
\r
95 Temp_Series=JJMASeries(0,0,MaxBar1,limit,Phase1,Length1,Temp_Series,bar,reset);
\r
96 //----+ ïðîâåðêà íà îòñóòñòâèå îøèáêè â ïðåäûäóùåé îïåðàöèè
\r
97 if(reset!=0){INDICATOR_COUNTED(-1);return(-1);}
\r
98 //+----------------------------------------------------------------------------+
\r
99 Temp_Series=JJMASeries(1,0,MaxBar2,limit,Phase2,Length2,Temp_Series,bar,reset);
\r
100 //----+ ïðîâåðêà íà îòñóòñòâèå îøèáêè â ïðåäûäóùåé îïåðàöèè
\r
101 if(reset!=0){INDICATOR_COUNTED(-1);return(-1);}
\r
102 //+----------------------------------------------------------------------------+
\r
103 J2JMA[bar]=Temp_Series;
\r
105 //---- çàâåðøåíèå âû÷èñëåíèé çíà÷åíèé èíäèêàòîðà
\r
108 //+---------------------------------------------------------------------------------------------------------------------------+
\r
109 //----+ Ââåäåíèå ôóíêöèè JJMASeries (ôàéë JJMASeries.mqh ñëåäóåò ïîëîæèòü â ïàïêó (äèðåêòîðèþ): MetaTrader\experts\include)
\r
110 //----+ Ââåäåíèå ôóíêöèè JJMASeriesReset (äîïîëíèòåëüíàÿ ôóíêöèÿ ôàéëà JJMASeries.mqh)
\r
111 //----+ Ââåäåíèå ôóíêöèè INDICATOR_COUNTED(äîïîëíèòåëüíàÿ ôóíêöèÿ ôàéëà JJMASeries.mqh)
\r
112 #include <JJMASeries.mqh>
\r
113 //+---------------------------------------------------------------------------------------------------------------------------+
\r
114 //----+ Ââåäåíèå ôóíêöèè PriceSeries, ôàéë PriceSeries.mqh ñëåäóåò ïîëîæèòü â ïàïêó (äèðåêòîðèþ): MetaTrader\experts\include
\r
115 //----+ Ââåäåíèå ôóíêöèè PriceSeriesAlert (äîïîëíèòåëüíàÿ ôóíêöèÿ ôàéëà PriceSeries.mqh)
\r
116 #include <PriceSeries.mqh>
\r
117 //+---------------------------------------------------------------------------------------------------------------------------+