0
Views
0
Downloads
0
Favorites
BnB_v1
//+---------------------------------------------------------------------+
//| BnB.mq5 |
//| Copyright © 2012, Zhaslan |
//| |
//+---------------------------------------------------------------------+
//| Äëÿ ðàáîòû èíäèêàòîðà ñëåäóåò ïîëîæèòü ôàéë SmoothAlgorithms.mqh |
//| â ïàïêó (äèðåêòîðèþ): êàòàëîã_äàííûõ_òåðìèíàëà\\MQL5\Include |
//+---------------------------------------------------------------------+
//---- àâòîðñòâî èíäèêàòîðà
#property copyright "Copyright © 2012, Zhaslan"
//---- ññûëêà íà ñàéò àâòîðà
#property link ""
#property description "BnB"
//---- íîìåð âåðñèè èíäèêàòîðà
#property version "1.01"
//---- îòðèñîâêà èíäèêàòîðà â îòäåëüíîì îêíå
#property indicator_separate_window
//---- äëÿ ðàñ÷¸òà è îòðèñîâêè èíäèêàòîðà èñïîëüçîâàíî äâà áóôåðà
#property indicator_buffers 2
//---- èñïîëüçîâàíî îäíî ãðàôè÷åñêîå ïîñòðîåíèå
#property indicator_plots 1
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè èíäèêàòîðà 1 |
//+----------------------------------------------+
//--- îòðèñîâêà èíäèêàòîðà â âèäå öâåòíîãî îáëàêà
#property indicator_type1 DRAW_FILLING
//--- â êà÷åñòâå öâåòîâ èíäèêàòîðà èñïîëüçîâàíû
#property indicator_color1 clrMediumOrchid,clrDodgerBlue
//---- îòîáðàæåíèå ìåòêè èíäèêàòîðà
#property indicator_label1 "BnB"
//+----------------------------------------------+
//| Îïèñàíèå êëàññà CXMA |
//+----------------------------------------------+
#include <SmoothAlgorithms.mqh>
//+----------------------------------------------+
//---- îáúÿâëåíèå ïåðåìåííûõ êëàññîâ CXMA è CMomentum èç ôàéëà SmoothAlgorithms.mqh
CXMA XMA1,XMA2;
//+----------------------------------------------+
//| îáúÿâëåíèå êîíñòàíò |
//+----------------------------------------------+
#define RESET 0 // Êîíñòàíòà äëÿ âîçâðàòà òåðìèíàëó êîìàíäû íà ïåðåñ÷¸ò èíäèêàòîðà
//+----------------------------------------------+
//| îáúÿâëåíèå ïåðå÷èñëåíèé |
//+----------------------------------------------+
/*enum Smooth_Method - ïåðå÷èñëåíèå îáúÿâëåíî â ôàéëå SmoothAlgorithms.mqh
{
MODE_SMA_, //SMA
MODE_EMA_, //EMA
MODE_SMMA_, //SMMA
MODE_LWMA_, //LWMA
MODE_JJMA, //JJMA
MODE_JurX, //JurX
MODE_ParMA, //ParMA
MODE_T3, //T3
MODE_VIDYA, //VIDYA
MODE_AMA, //AMA
}; */
//+----------------------------------------------+
//| Âõîäíûå ïàðàìåòðû èíäèêàòîðà |
//+----------------------------------------------+
input Smooth_Method XMA_Method=MODE_T3; // ìåòîä óñðåäíåíèÿ
input uint XLength=14; // ãëóáèíà óñðåäíåíèÿ
input int XPhase=15; // ïàðàìåòð ñãëàæèâàíèÿ,
//---- äëÿ JJMA èçìåíÿþùèéñÿ â ïðåäåëàõ -100 ... +100, âëèÿåò íà êà÷åñòâî ïåðåõîäíîãî ïðîöåññà;
//---- Äëÿ VIDIA ýòî ïåðèîä CMO, äëÿ AMA ýòî ïåðèîä ìåäëåííîé ñêîëüçÿùåé
input ENUM_APPLIED_VOLUME VolumeType=VOLUME_TICK; // îáú¸ì
//+----------------------------------------------+
//---- îáúÿâëåíèå äèíàìè÷åñêèõ ìàññèâîâ, êîòîðûå áóäóò â
// äàëüíåéøåì èñïîëüçîâàíû â êà÷åñòâå èíäèêàòîðíûõ áóôåðîâ
double UpBuffer[],DnBuffer[];
//---- Îáúÿâëåíèå öåëûõ ïåðåìåííûõ äëÿ õðàíåíèÿ õåíäëîâ èíäèêàòîðîâ
int Ind_Handle;
//---- Îáúÿâëåíèå öåëûõ ïåðåìåííûõ íà÷àëà îòñ÷¸òà äàííûõ
int min_rates_total;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---- Èíèöèàëèçàöèÿ ïåðåìåííûõ íà÷àëà îòñ÷¸òà äàííûõ
min_rates_total=XMA1.GetStartBars(XMA_Method,XLength,XPhase);
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
SetIndexBuffer(0,UpBuffer,INDICATOR_DATA);
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà â èíäèêàòîðíûé áóôåð
SetIndexBuffer(1,DnBuffer,INDICATOR_DATA);
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷¸òà îòðèñîâêè èíäèêàòîðà
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//--- ñîçäàíèå èìåíè äëÿ îòîáðàæåíèÿ â îòäåëüíîì ïîäîêíå è âî âñïëûâàþùåé ïîäñêàçêå
IndicatorSetString(INDICATOR_SHORTNAME,"BnB");
//--- îïðåäåëåíèå òî÷íîñòè îòîáðàæåíèÿ çíà÷åíèé èíäèêàòîðà
IndicatorSetInteger(INDICATOR_DIGITS,0);
//--- çàâåðøåíèå èíèöèàëèçàöèè
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(
const int rates_total, // êîëè÷åñòâî èñòîðèè â áàðàõ íà òåêóùåì òèêå
const int prev_calculated,// êîëè÷åñòâî èñòîðèè â áàðàõ íà ïðåäûäóùåì òèêå
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[])
{
//---- ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ ðàñ÷¸òà
if(rates_total<min_rates_total) return(RESET);
//---- Îáúÿâëåíèå ïåðåìåííûõ ñ ïëàâàþùåé òî÷êîé
double tic,diff,bears,bulls;
//---- Îáúÿâëåíèå öåëûõ ïåðåìåííûõ
int first,bar;
long vol;
//---- ðàñ÷¸ò ñòàðòîâîãî íîìåðà first äëÿ öèêëà ïåðåñ÷¸òà áàðîâ
if(prev_calculated>rates_total || prev_calculated<=0) // ïðîâåðêà íà ïåðâûé ñòàðò ðàñ÷¸òà èíäèêàòîðà
first=0; // ñòàðòîâûé íîìåð äëÿ ðàñ÷¸òà âñåõ áàðîâ
else first=prev_calculated-1; // ñòàðòîâûé íîìåð äëÿ ðàñ÷¸òà íîâûõ áàðîâ
//---- Îñíîâíîé öèêë ðàñ÷¸òà èíäèêàòîðà
for(bar=first; bar<rates_total && !IsStopped(); bar++)
{
if(VolumeType==VOLUME_TICK) vol=tick_volume[bar];
else vol=volume[bar];
if(!vol) vol=1;
tic=(high[bar]-low[bar])/vol;
diff=0.0;
if(open[bar]>close[bar]) diff=((high[bar]-low[bar])-(open[bar]-close[bar]))/(2*tic);
if(open[bar]<close[bar]) diff=((high[bar]-low[bar])-(close[bar]-open[bar]))/(2*tic);
//----
if(open[bar]>close[bar]) bulls=(open[bar]-close[bar])/tic+diff;
else bulls=diff;
//----
if(open[bar]<close[bar]) bears=(close[bar]-open[bar])/tic+diff;
else bears=diff;
//----
UpBuffer[bar]=XMA1.XMASeries(0,prev_calculated,rates_total,XMA_Method,XPhase,XLength,bulls,bar,false);
DnBuffer[bar]=XMA2.XMASeries(0,prev_calculated,rates_total,XMA_Method,XPhase,XLength,bears,bar,false);
}
//----
return(rates_total);
}
//+------------------------------------------------------------------+
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
---