//+------------------------------------------------------------------+
//| Necarb01.mq4 |
//| Copyright © 2009, MetaQuotes Software Corp. |
//| _http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
//---- input parameters
extern string ExtParam1="GBPJPY";
extern string ExtParam2="GBPCHF";
extern color ExtParam3=DeepSkyBlue;
extern color ExtParam4=MediumSeaGreen;
extern int ExtParam5=10;
extern int ExtParam6=1000;
extern int ExtParam7=21;
extern int ExtParam8=13;
extern int ExtParam9=2;
extern int ExtParam10=6;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,ExtParam1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,ExtParam2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars -= 10;
int per1,per2;
per1 = ExtParam7; // MA_per;
per2 = ExtParam8; // MA_fast;
//----
int l = Bars - IndicatorCounted();
int k;
for(k = 0; k < l; k++)
{
ExtMapBuffer1[k] = //задаем отрисовку линии первого инструмента
(
iMA(ExtParam1,Period(),per2,0,
ExtParam9,
ExtParam10,
iBarShift(ExtParam1,0,Time[k],false))-iMA(ExtParam1,Period(),
per1,0,
ExtParam9,
ExtParam10,
iBarShift(ExtParam1,0,Time[k],false)))*ExtParam5;
ExtMapBuffer2[k] = //задаем отрисовку линии второго инструмента
(
iMA(ExtParam2,Period(),per2,0,
ExtParam9,
ExtParam10,
iBarShift(ExtParam2,0,Time[k],false))-iMA(ExtParam2,Period(),
per1,0,
ExtParam9,
ExtParam10,
iBarShift(ExtParam2,0,Time[k],false)))*ExtParam6;
}
//----
string d1 = DoubleToStr(ExtMapBuffer1[0] - ExtMapBuffer2[0],3);
string in1 = ExtParam1 + " :син.линия " + ExtParam2 +
" :красн.линия " + "``Спред`` := " + d1 + " " ;
IndicatorShortName(in1);
//----
return(0);
}
//+------------------------------------------------------------------+