//+------------------------------------------------------------------+ //| AlligatorBollingerBandsFraktal.mq4 | //| Mojo_Head © 2012 | //| mojohead@bk.ru | //+------------------------------------------------------------------+ #property copyright "Mojo_Head © 2012" #property link "mojohead@bk.ru" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Lime #property indicator_color4 Gold #property indicator_color5 Black//C'250,250,250' #property indicator_color6 Gold #property indicator_color7 Peru #property indicator_color8 MediumOrchid #property indicator_width7 1 #property indicator_width8 1 /* Metod MODE_SMA 0 Простое скользящее среднее MODE_EMA 1 Экспоненциальное скользящее среднее MODE_SMMA 2 Сглаженное скользящее среднее MODE_LWMA 3 Линейно-взвешенное скользящее среднее Price PRICE_CLOSE 0 Цена закрытия PRICE_OPEN 1 Цена открытия PRICE_HIGH 2 Максимальная цена PRICE_LOW 3 Минимальная цена PRICE_MEDIAN 4 Средняя цена, (high+low)/2 PRICE_TYPICAL 5 Типичная цена, (high+low+close)/3 PRICE_WEIGHTED 6 Взвешенная цена закрытия, (high+low+close+close)/4 */ //---- input parameters extern int JawsPeriod=13; extern int JawsShift=8; extern int TeethPeriod=8; extern int TeethShift=5; extern int LipsPeriod=5; extern int LipsShift=3; extern int bbPeriod=20; extern int Metod=0; extern int Price=0; extern int bbShift=0; extern double bbDev=2.0; extern int fBars = 2; int AveragePeriod=5; //---- indicator buffers double allblue[]; double allred[]; double allgren[]; double hbb[]; double mbb[]; double lbb[]; double frup[]; double frdn[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0,allblue); SetIndexBuffer(1,allred); SetIndexBuffer(2,allgren); SetIndexBuffer(3,hbb); SetIndexBuffer(4,mbb); SetIndexBuffer(5,lbb); SetIndexBuffer(6,frup); SetIndexBuffer(7,frdn); //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); SetIndexStyle(4,DRAW_LINE); SetIndexStyle(5,DRAW_LINE); SetIndexStyle(6,DRAW_ARROW); SetIndexStyle(7,DRAW_ARROW); SetIndexLabel(0, "All jaws"); SetIndexLabel(1, "All teeth"); SetIndexLabel(2, "All lips"); SetIndexLabel(3, "BB upp (" + bbPeriod + ")"); SetIndexLabel(4, "BB med (" + bbPeriod + ")"); SetIndexLabel(5, "BB dwn (" + bbPeriod + ")"); SetIndexLabel(6, "Fr upp (" + fBars + ")"); SetIndexLabel(7, "Fr dwn (" + fBars + ")"); SetIndexArrow(6,217); SetIndexEmptyValue(6,0.0); SetIndexArrow(7,218); SetIndexEmptyValue(7,0.0); return(0); } //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ int start() { double hFractal = 0, lFractal = 0, hBand = 0, mBand = 0, lBand = 0; int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { allblue[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); allred[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); allgren[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); ////////* расчет линий болинджера */ bband(bbPeriod, bbShift, bbDev, i, hBand, mBand, lBand); hbb[i] = hBand; mbb[i] = mBand; lbb[i] = lBand; ///////* расчет фракталов */ fractal(High, Low, i, fBars, hFractal, lFractal); if (hFractal > 0) frup[i+fBars+1] = hFractal; if (lFractal > 0) frdn[i+fBars+1] = lFractal; } //---- done return(0); } //+------------------------------------------------------------------+ // --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->> void bband(int bbPeriod, int bbShift, double bbDev, int index, double& hBand, double& mBand, double& lBand) { double sum = 0, ave = 0, sko = 0; int j = 0; mBand = iMA(NULL,0,bbPeriod,bbShift,Metod,Price,index); sum = 0; for (j = 0; j < bbPeriod; j++) sum += Close[index+j]; ave = sum / bbPeriod; sum = 0; for (j = 0; j < bbPeriod; j++) sum += (Close[index+j] - ave) * (Close[index+j] - ave);sko = MathSqrt(sum / bbPeriod); hBand = mBand + bbDev * sko;lBand = mBand - bbDev * sko; } // --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->> // --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->> void fractal(double arUp[], double arDown[], int index, int bars, double& hFractal, double& lFractal) { int pos = 0, i = 0; hFractal = 0; lFractal = 0; pos = index + bars + 1; /* фрактал верх */ for(i = 1; i <= bars; i++) { if(N(arUp[pos] - arUp[pos - i]) <= 0) { break; } /* правая сторона */ if(N(arUp[pos] - arUp[pos + i]) <= 0) { break; } /* левая сторона */ } /* запоминаем значение на баре, где верхний фрактал */ if (i == bars + 1) hFractal = arUp[pos]; /* фрактал низ */ for(i = 1; i <= bars; i++) { if(N(arDown[pos] - arDown[pos - i]) >= 0) { break; } /* правая сторона */ if(N(arDown[pos] - arDown[pos + i]) >= 0) { break; } /* левая сторона */ } /* запоминаем значение на баре, где нижний фрактал */ if (i == bars + 1) lFractal = arDown[pos]; } // --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->> double N(double source, string symb="0") { int digits = Digits; if (symb == "0") { digits = MarketInfo(Symbol(), MODE_DIGITS); } return(NormalizeDouble(source,digits)); } // --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>
как минимум должен быть код такой в форуме
второй момент это что:
fractal(High, Low, i, fBars, hFractal, lFractal);
почему у них нет индекса и как он работал ранее?
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Доброго времени суток.
Столкнулся с нежеланием платформы использовать старый добрый индикатор после компиляции, хотя до компиляции исправно работал.
Вот собственно и сам код.
//+------------------------------------------------------------------+
//| AlligatorBollingerBandsFraktal.mq4 |
//| Mojo_Head © 2012 |
//| mojohead@bk.ru |
//+------------------------------------------------------------------+
#property copyright "Mojo_Head © 2012"
#property link "mojohead@bk.ru"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Gold
#property indicator_color5 Black//C'250,250,250'
#property indicator_color6 Gold
#property indicator_color7 Peru
#property indicator_color8 MediumOrchid
#property indicator_width7 1
#property indicator_width8 1
/*
Metod
MODE_SMA 0 Простое скользящее среднее
MODE_EMA 1 Экспоненциальное скользящее среднее
MODE_SMMA 2 Сглаженное скользящее среднее
MODE_LWMA 3 Линейно-взвешенное скользящее среднее
Price
PRICE_CLOSE 0 Цена закрытия
PRICE_OPEN 1 Цена открытия
PRICE_HIGH 2 Максимальная цена
PRICE_LOW 3 Минимальная цена
PRICE_MEDIAN 4 Средняя цена, (high+low)/2
PRICE_TYPICAL 5 Типичная цена, (high+low+close)/3
PRICE_WEIGHTED 6 Взвешенная цена закрытия, (high+low+close+close)/4
*/
//---- input parameters
extern int JawsPeriod=13;
extern int JawsShift=8;
extern int TeethPeriod=8;
extern int TeethShift=5;
extern int LipsPeriod=5;
extern int LipsShift=3;
extern int bbPeriod=20;
extern int Metod=0;
extern int Price=0;
extern int bbShift=0;
extern double bbDev=2.0;
extern int fBars = 2;
int AveragePeriod=5;
//---- indicator buffers
double allblue[];
double allred[];
double allgren[];
double hbb[];
double mbb[];
double lbb[];
double frup[];
double frdn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,allblue);
SetIndexBuffer(1,allred);
SetIndexBuffer(2,allgren);
SetIndexBuffer(3,hbb);
SetIndexBuffer(4,mbb);
SetIndexBuffer(5,lbb);
SetIndexBuffer(6,frup);
SetIndexBuffer(7,frdn);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(6,DRAW_ARROW);
SetIndexStyle(7,DRAW_ARROW);
SetIndexLabel(0, "All jaws");
SetIndexLabel(1, "All teeth");
SetIndexLabel(2, "All lips");
SetIndexLabel(3, "BB upp (" + bbPeriod + ")");
SetIndexLabel(4, "BB med (" + bbPeriod + ")");
SetIndexLabel(5, "BB dwn (" + bbPeriod + ")");
SetIndexLabel(6, "Fr upp (" + fBars + ")");
SetIndexLabel(7, "Fr dwn (" + fBars + ")");
SetIndexArrow(6,217);
SetIndexEmptyValue(6,0.0);
SetIndexArrow(7,218);
SetIndexEmptyValue(7,0.0);
return(0);
}
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
int start()
{
double hFractal = 0, lFractal = 0, hBand = 0, mBand = 0, lBand = 0;
int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++)
{
allblue[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
allred[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
allgren[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
////////* расчет линий болинджера */
bband(bbPeriod, bbShift, bbDev, i, hBand, mBand, lBand);
hbb[i] = hBand; mbb[i] = mBand; lbb[i] = lBand;
///////* расчет фракталов */
fractal(High, Low, i, fBars, hFractal, lFractal);
if (hFractal > 0) frup[i+fBars+1] = hFractal;
if (lFractal > 0) frdn[i+fBars+1] = lFractal;
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
// --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>
void bband(int bbPeriod, int bbShift, double bbDev, int index, double& hBand, double& mBand, double& lBand)
{
double sum = 0, ave = 0, sko = 0;
int j = 0;
mBand = iMA(NULL,0,bbPeriod,bbShift,Metod,Price,index);
sum = 0;
for (j = 0; j < bbPeriod; j++) sum += Close[index+j]; ave = sum / bbPeriod;
sum = 0;
for (j = 0; j < bbPeriod; j++) sum += (Close[index+j] - ave) * (Close[index+j] - ave);sko = MathSqrt(sum / bbPeriod);
hBand = mBand + bbDev * sko;lBand = mBand - bbDev * sko;
}
// --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>
// --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>
void fractal(double arUp[], double arDown[], int index, int bars, double& hFractal, double& lFractal)
{
int pos = 0, i = 0;
hFractal = 0; lFractal = 0;
pos = index + bars + 1;
/* фрактал верх */
for(i = 1; i <= bars; i++)
{
if(N(arUp[pos] - arUp[pos - i]) <= 0) { break; } /* правая сторона */
if(N(arUp[pos] - arUp[pos + i]) <= 0) { break; } /* левая сторона */
}
/* запоминаем значение на баре, где верхний фрактал */
if (i == bars + 1) hFractal = arUp[pos];
/* фрактал низ */
for(i = 1; i <= bars; i++)
{
if(N(arDown[pos] - arDown[pos - i]) >= 0) { break; } /* правая сторона */
if(N(arDown[pos] - arDown[pos + i]) >= 0) { break; } /* левая сторона */
}
/* запоминаем значение на баре, где нижний фрактал */
if (i == bars + 1) lFractal = arDown[pos];
}
// --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>
double N(double source, string symb="0")
{
int digits = Digits;
if (symb == "0")
{
digits = MarketInfo(Symbol(), MODE_DIGITS);
}
return(NormalizeDouble(source,digits));
}
// --->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>--->>