Williams Mokoena / Perfil
Amigos
Pedidos
Adicione amigos através do seu perfil ou da pesquisa de usuário e você poderá ver se eles estão online
Enviados
Williams Mokoena
CRT
//+------------------------------------------------------------------+
//| CRT.mq5 |
//| ICT Candle Range Theory |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3
#property indicator_label1 "CRT-H"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
#property indicator_width1 2
#property indicator_label2 "CRT-L"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrDodgerBlue
#property indicator_width2 2
#property indicator_label3 "CRT-50%"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrGold
#property indicator_style3 STYLE_DASH
#property indicator_width3 2
input int InpCRTCandles = 3; // How many candles make CRT range
input bool InpShowBox = true;
double ExtHigh[], ExtLow[], ExtMid[];
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,ExtHigh,INDICATOR_DATA);
SetIndexBuffer(1,ExtLow,INDICATOR_DATA);
SetIndexBuffer(2,ExtMid,INDICATOR_DATA);
ArraySetAsSeries(ExtHigh,true);
ArraySetAsSeries(ExtLow,true);
ArraySetAsSeries(ExtMid,true);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
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[])
{
ArraySetAsSeries(time,true);
ArraySetAsSeries(open,true);
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(close,true);
int start = prev_calculated==0? 50 : prev_calculated-1;
for(int i=start; i>=0; i--)
{
if(i+InpCRTCandles >= rates_total) continue;
// CRT = High/Low of last X candles
double crtH = high[i+1];
double crtL = low[i+1];
for(int k=1; k<=InpCRTCandles; k++)
{
crtH = MathMax(crtH, high[i+k]);
crtL = MathMin(crtL, low[i+k]);
}
double crtM = (crtH + crtL) / 2.0;
ExtHigh[i] = crtH;
ExtLow[i] = crtL;
ExtMid[i] = crtM;
if(InpShowBox && i==1)
{
string boxName = "CRT_BOX_"+(string)time[i];
// Delete old box
if(ObjectFind(0,"CRT_BOX_CURR")>=0) ObjectDelete(0,"CRT_BOX_CURR");
ObjectCreate(0,"CRT_BOX_CURR",OBJ_RECTANGLE,0,time[i+InpCRTCandles],crtH,time[i],crtL);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_COLOR,clrDodgerBlue);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_STYLE,STYLE_DOT);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_BACK,true);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_FILL,true);
color fill = clrDodgerBlue;
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_BGCOLOR,fill);
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| CRT.mq5 |
//| ICT Candle Range Theory |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3
#property indicator_label1 "CRT-H"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
#property indicator_width1 2
#property indicator_label2 "CRT-L"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrDodgerBlue
#property indicator_width2 2
#property indicator_label3 "CRT-50%"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrGold
#property indicator_style3 STYLE_DASH
#property indicator_width3 2
input int InpCRTCandles = 3; // How many candles make CRT range
input bool InpShowBox = true;
double ExtHigh[], ExtLow[], ExtMid[];
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,ExtHigh,INDICATOR_DATA);
SetIndexBuffer(1,ExtLow,INDICATOR_DATA);
SetIndexBuffer(2,ExtMid,INDICATOR_DATA);
ArraySetAsSeries(ExtHigh,true);
ArraySetAsSeries(ExtLow,true);
ArraySetAsSeries(ExtMid,true);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
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[])
{
ArraySetAsSeries(time,true);
ArraySetAsSeries(open,true);
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(close,true);
int start = prev_calculated==0? 50 : prev_calculated-1;
for(int i=start; i>=0; i--)
{
if(i+InpCRTCandles >= rates_total) continue;
// CRT = High/Low of last X candles
double crtH = high[i+1];
double crtL = low[i+1];
for(int k=1; k<=InpCRTCandles; k++)
{
crtH = MathMax(crtH, high[i+k]);
crtL = MathMin(crtL, low[i+k]);
}
double crtM = (crtH + crtL) / 2.0;
ExtHigh[i] = crtH;
ExtLow[i] = crtL;
ExtMid[i] = crtM;
if(InpShowBox && i==1)
{
string boxName = "CRT_BOX_"+(string)time[i];
// Delete old box
if(ObjectFind(0,"CRT_BOX_CURR")>=0) ObjectDelete(0,"CRT_BOX_CURR");
ObjectCreate(0,"CRT_BOX_CURR",OBJ_RECTANGLE,0,time[i+InpCRTCandles],crtH,time[i],crtL);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_COLOR,clrDodgerBlue);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_STYLE,STYLE_DOT);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_BACK,true);
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_FILL,true);
color fill = clrDodgerBlue;
ObjectSetInteger(0,"CRT_BOX_CURR",OBJPROP_BGCOLOR,fill);
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
: