Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Zerolagstochs_v5
// Ðåäàêòèðîâàíèå è èñïðàâëåíèÿ 22.09.2008 Íèêîëàé Êîñèöèí
//+X================================================================X+
//| ZerolagStochs.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+X================================================================X+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "perky_z@yahoo.com"
//---- îòðèñîâêà èíäèêàòîðà â îòäåëüîì îêíå
#property indicator_separate_window
//---- êîëè÷åñòâî èíäèêàòîðíûõ áóôåðîâ
#property indicator_buffers 2
//---- öâåòà èíäèêàòîðà
#property indicator_color1 Blue
#property indicator_color2 Red
//---- Îáúÿâëåíèå èíäèêàòîðíûõ áóôåðîâ
double FastTrendBuffer[];
double LowTrendBuffer[];
//---- Îáúÿâëåíèå öåëûõ êîíñòàíò
int StartBar;
//---- Îáúÿâëåíèå êîíñòàíò ñ ïëàâàþùåé òî÷êîé
double smoothConst, smoothing;
//+X================================================================X+
//| ZerolagStochs indicator initialization function |
//+X================================================================X+
int init()
{
//---+
//---- 2 èíäèêàòîðíûõ áóôåðà èñïîëüçîâàíû äëÿ ñ÷¸òà
SetIndexBuffer(0, FastTrendBuffer);
SetIndexBuffer(1, LowTrendBuffer );
//---- îïðåäåëåíèå ñòèëÿ èñïîëíåíèÿ ãðàôèêà
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
//---- Óñòàíîâêà ôîðìàòà òî÷íîñòè îòîáðàæåíèÿ èíäèêàòîðà
IndicatorDigits(Digits);
//---- Èìÿ èíäèêàòîðà â ñóáúîêíå
IndicatorShortName("Zero Lag Stocs");
//---- Ëýéáû äëÿ èíäèêàòîðíûõ ëèíèé
SetIndexLabel(0, "FastTrendLine");
SetIndexLabel(1, "LowTrendLine");
//---- Èíèöèàëèçàöèÿ êîíñòàíò
smoothing = 15;
StartBar = 89 + 21 + 1;
smoothConst = (smoothing - 1.0) / smoothing;
//---- óñòàíîâêà íîìåðà áàðà,
//íà÷èíàÿ ñ êîòîðîãî áóäåò îòðèñîâûâàòüñÿ èíäèêàòîð
SetIndexDrawBegin(0, StartBar - 1);
SetIndexDrawBegin(1, StartBar);
//---- Çàâåðøåíèå èíèöèàëèçàöèè
return(0);
//---+
}
//+X================================================================X+
//| ZerolagStochs indicator start function |
//+X================================================================X+
int start()
{
//---+
//---- ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ ðàñ÷¸òà
if (Bars < StartBar)
return(0);
//---- Îáúÿâëåíèå ñòàòè÷åñêèõ ïåðåìåííûõ
static bool TrueStart;
//---- Îáúÿâëåíèå ïåðåìåííûõ ñ ïëàâàþùåé òî÷êîé
double FastTrend, LowTrend;
double Stoch1, Stoch2, Stoch3, Stoch4, Stoch5;
//----+ Îáúÿâëåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîñ÷èòàííûõ áàðîâ
int limit, MaxBar, bar, counted_bars = IndicatorCounted();
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
if (counted_bars < 0)
return(-1);
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí
if (counted_bars > 0)
counted_bars--;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà,
//íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò âñåõ áàðîâ
MaxBar = Bars - 1 - StartBar;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà,
//íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò òîëüêî íîâûõ áàðîâ
limit = (Bars - 1 - counted_bars);
//---- èíèöèàëèçàöèÿ íóëÿ
if (limit >= MaxBar || !TrueStart)
{
limit = MaxBar;
TrueStart = true;
//----
for (bar = Bars - 1; bar > MaxBar; bar--)
{
FastTrendBuffer[bar] = 0.0;
LowTrendBuffer [bar] = 0.0;
}
LowTrendBuffer[MaxBar + 1] = 0.0; //???
}
//---+ ÎÑÍÎÂÍÎÉ ÖÈÊË ÐÀÑרÒÀ ÈÍÄÈÊÀÒÎÐÀ
for (bar = limit; bar>= 0; bar--)
{
Stoch1 = 0.05 * iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, NULL, MODE_MAIN, bar);
Stoch2 = 0.10 * iStochastic(NULL, 0, 21, 5, 3, MODE_SMA, NULL, MODE_MAIN, bar);
Stoch3 = 0.16 * iStochastic(NULL, 0, 34, 8, 3, MODE_SMA, NULL, MODE_MAIN, bar);
Stoch4 = 0.26 * iStochastic(NULL, 0, 55, 13, 3, MODE_SMA, NULL, MODE_MAIN, bar);
Stoch5 = 0.43 * iStochastic(NULL, 0, 89, 21, 3, MODE_SMA, NULL, MODE_MAIN, bar); // StartBar = 89 + 21 + 1;!!!
//----
FastTrend = Stoch1 + Stoch2 + Stoch3 + Stoch4 + Stoch5;
//----
LowTrend = FastTrend / smoothing + LowTrendBuffer[bar + 1] * smoothConst;
//----
FastTrendBuffer[bar] = FastTrend;
LowTrendBuffer [bar] = LowTrend;
}
//---+
return(0);
//---+
}
//+X----------------------------------------------------------------X+er [bar] = 0.0;
}
FastTrend = ZerolagStochs(Symbol(), 0, MODE_SMA, MODE_MAIN, 3, MaxBar + 1);
LowTrendBuffer[MaxBar + 1] = FastTrend / smoothing;
}
//---+ ÎÑÍÎÂÍÎÉ ÖÈÊË ÐÀÑרÒÀ ÈÍÄÈÊÀÒÎÐÀ
for (bar = limit; bar>= 0; bar--)
{
FastTrend = ZerolagStochs(Symbol(), 0, MODE_SMA, MODE_MAIN, 3, bar);
//----
LowTrend = FastTrend / smoothing + LowTrendBuffer[bar + 1] * smoothConst;
//----
FastTrendBuffer[bar] = FastTrend;
LowTrendBuffer [bar] = LowTrend;
}
//---+
return(0);
//---+
}
//+X----------------------------------------------------------------X+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---