Sei sulla pagina 1di 2

//+------------------------------------------------------------------+

//| TCCONE.mq5 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_plots 2
//--- plot VENDA
#property indicator_label1 "VENDA"
#property indicator_type1 DRAW_CANDLES
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot COMPRA
#property indicator_label2 "COMPRA"
#property indicator_type2 DRAW_CANDLES
#property indicator_color2 clrDarkGreen
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- indicator buffers
double VENDABuffer1[];
double VENDABuffer2[];
double VENDABuffer3[];
double VENDABuffer4[];
double COMPRABuffer1[];
double COMPRABuffer2[];
double COMPRABuffer3[];
double COMPRABuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,VENDABuffer1,INDICATOR_DATA);
SetIndexBuffer(1,VENDABuffer2,INDICATOR_DATA);
SetIndexBuffer(2,VENDABuffer3,INDICATOR_DATA);
SetIndexBuffer(3,VENDABuffer4,INDICATOR_DATA);
SetIndexBuffer(4,COMPRABuffer1,INDICATOR_DATA);
SetIndexBuffer(5,COMPRABuffer2,INDICATOR_DATA);
SetIndexBuffer(6,COMPRABuffer3,INDICATOR_DATA);
SetIndexBuffer(7,COMPRABuffer4,INDICATOR_DATA);

//---
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[])
{
//---
for (int i=0; i<rates_total; i++)
{
if(low[i]<low[i-1] && high[i]<high[i-1])
{
VENDABuffer1[i]=high[i];
}
else
{
VENDABuffer1[i]=0;
}

if(low[i]>low[i-1] && high[i]>high[i-1])


{
COMPRABuffer1[i]=low[i];
}
else
{
COMPRABuffer1[i]=0;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+

Potrebbero piacerti anche