встроенный индикатор рисует прямоугольнички ограниченные тенями предыдущей и следующей свечами
куда встроенный и у кого?

встроенный индикатор рисует прямоугольнички ограниченные тенями предыдущей и следующей свечами
цена касается на текущей свече крайней границы выделенной зоны
//+------------------------------------------------------------------+
//| Custom MACD.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Silver
#property indicator_color2 Red
#property indicator_width1 2
//--- indicator parameters
input int InpFastEMA=12; // Fast EMA Period
input int InpSlowEMA=26; // Slow EMA Period
input int InpSignalSMA=9; // Signal SMA Period
//--- indicator buffers
double ExtMacdBuffer[];
double ExtSignalBuffer[];
double up[];
double dn[];
//--- right input parameters flag
bool ExtParameters=false;
bool b=1,s=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
IndicatorDigits(Digits+1);
//--- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,InpSignalSMA);
//--- indicator buffers mapping
SetIndexBuffer(0,ExtMacdBuffer);
SetIndexBuffer(1,ExtSignalBuffer);
SetIndexStyle(2,DRAW_ARROW,0,1,Aqua);
SetIndexArrow(2,233);
SetIndexBuffer(2,up);
SetIndexStyle(3,DRAW_ARROW,0,1,Red);
SetIndexArrow(3,234);
SetIndexBuffer(3,dn);
//--- name for DataWindow and indicator subwindow label
IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
SetIndexLabel(0,"MACD");
SetIndexLabel(1,"Signal");
//--- check for input parameters
if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
{
Print("Wrong input parameters");
ExtParameters=false;
return(INIT_FAILED);
}
else
ExtParameters=true;
//--- initialization done
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
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[])
{
int i,limit;
//---
if(rates_total<=InpSignalSMA || !ExtParameters)
return(0);
//--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
//--- macd counted in the 1-st buffer
for(i=0; i<limit; i++)
ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//--- signal line counted in the 2-nd buffer
SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
for(int i=0; i<1111; i++)
{
if(ExtMacdBuffer[i]<0 && ExtMacdBuffer[i]>ExtMacdBuffer[i+1] && ExtMacdBuffer[i+1]<ExtMacdBuffer[i+2] && b)
{
up[i]=ExtMacdBuffer[i+1];
b=0;s=1;
}
if(ExtMacdBuffer[i]>0 && ExtMacdBuffer[i]<ExtMacdBuffer[i+1] && ExtMacdBuffer[i+1]>ExtMacdBuffer[i+2] && s)
{
dn[i]=ExtMacdBuffer[i+1];
b=1;s=0;
}
}
//--- done
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Support_and_Resistance.mq5 |
//| Copyright © 2005, Дмитрий |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//---- номер версии индикатора
#property version "1.12"
//---- отрисовка индикатора в главном окне
#property indicator_chart_window
//---- для расчета и отрисовки индикатора использовано два буфера
#property indicator_buffers 2
//---- использовано всего два графических построения
#property indicator_plots 2
//+----------------------------------------------+
//| объявление констант |
//+----------------------------------------------+
#define RESET 0 // Константа для возврата терминалу команды на пересчет индикатора
//+----------------------------------------------+
//| Параметры отрисовки медвежьего индикатора |
//+----------------------------------------------+
//---- отрисовка индикатора 1 в виде символа
#property indicator_type1 DRAW_LINE
//---- в качестве цвета уровней поддержки использован розовый цвет
#property indicator_color1 clrMagenta
//---- толщина линии индикатора 1 равна 1
#property indicator_width1 1
//---- отображение метки поддержки
#property indicator_label1 "Support"
//+----------------------------------------------+
//| Параметры отрисовки бычьго индикатора |
//+----------------------------------------------+
//---- отрисовка индикатора 2 в виде символа
#property indicator_type2 DRAW_LINE
//---- в качестве цвета уровней сопротивления использован зеленый цвет
#property indicator_color2 clrLime
//---- толщина линии индикатора 2 равна 1
#property indicator_width2 1
//---- отображение метки сопротивления
#property indicator_label2 "Resistance"
//+----------------------------------------------+
//| Входные параметры индикатора |
//+----------------------------------------------+
//+----------------------------------------------+
//---- объявление динамических массивов, которые будут в
// дальнейшем использованы в качестве индикаторных буферов
double SellBuffer[];
double BuyBuffer[];
//---
int StartBars;
int FRA_Handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---- инициализация глобальных переменных
StartBars=11;
//---- получение хендла индикатора iFractals
FRA_Handle=iFractals(NULL,0);
if(FRA_Handle==INVALID_HANDLE)
{
Print(" Не удалось получить хендл индикатора iFractals");
return(INIT_FAILED);
}
//---- превращение динамического массива в индикаторный буфер
SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
//---- осуществление сдвига начала отсчета отрисовки индикатора 1
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartBars);
//--- создание метки для отображения в DataWindow
PlotIndexSetString(0,PLOT_LABEL,"Support");
//---- индексация элементов в буфере как в таймсерии
ArraySetAsSeries(SellBuffer,true);
//---- превращение динамического массива в индикаторный буфер
SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
//---- осуществление сдвига начала отсчета отрисовки индикатора 2
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,StartBars);
//--- создание метки для отображения в DataWindow
PlotIndexSetString(1,PLOT_LABEL,"Resistance");
//---- индексация элементов в буфере как в таймсерии
ArraySetAsSeries(BuyBuffer,true);
//---- Установка формата точности отображения индикатора
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- имя для окон данных и лэйба для субъокон
string short_name="Support & Resistance";
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- завершение инициализации
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(BarsCalculated(FRA_Handle)<rates_total || rates_total<StartBars) return(RESET);
//---- объявления локальных переменных
int to_copy,limit,bar;
double FRAUp[],FRALo[],upVel,loVel;
//---- расчеты необходимого количества копируемых данных
//---- и стартового номера limit для цикла пересчета баров
if(prev_calculated>rates_total || prev_calculated<=0)// проверка на первый старт расчета индикатора
{
to_copy=rates_total; // расчетное количество всех баров
limit=rates_total-StartBars-1; // стартовый номер для расчета всех баров
}
else
{
to_copy=rates_total-prev_calculated+3; // расчетное количество только новых баров
limit=rates_total-prev_calculated+2; // стартовый номер для расчета новых баров
}
//---- индексация элементов в массивах как в таймсериях
ArraySetAsSeries(FRAUp,true);
ArraySetAsSeries(FRALo,true);
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
//---- копируем вновь появившиеся данные в массивы
if(CopyBuffer(FRA_Handle,0,0,to_copy,FRAUp)<=0) return(RESET);
if(CopyBuffer(FRA_Handle,1,0,to_copy,FRALo)<=0) return(RESET);
//---- основной цикл расчета индикатора
for(bar=limit; bar>=0; bar--)
{
BuyBuffer[bar]=NULL;
SellBuffer[bar]=NULL;
//----
upVel=FRAUp[bar];
loVel=FRALo[bar];
//----
if(upVel && upVel!=EMPTY_VALUE) BuyBuffer[bar]=high[bar]; else BuyBuffer[bar]=BuyBuffer[bar+1];
if(loVel && loVel!=EMPTY_VALUE) SellBuffer[bar]=low[bar]; else SellBuffer[bar]=SellBuffer[bar+1];
}
//----
return(rates_total);
}
//+------------------------------------------------------------------+
AM2