通道 DJ_Lines
//+------------------------------------------------------------------+
//| DJ_Lines.mq4 |
//| Copyright @2005, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "下载更多外汇EA,外汇指标,交易系统,就到【外汇EA之家】"
#property link "http://www.eazhijia.com"
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Yellow
#property indicator_color5 Yellow
#property indicator_color6 LimeGreen
#property indicator_color7 LimeGreen
extern int show_comment=1;
extern int how_long=1000;
double E2[];
double ff[];
double E4[];
double E5[];
double E6[];
double E7[];
double E8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(void)
{
SetIndexBuffer(0, E2);
SetIndexBuffer(1, ff);
SetIndexBuffer(2, E4);
SetIndexBuffer(3, E5);
SetIndexBuffer(4, E6);
SetIndexBuffer(5, E7);
SetIndexBuffer(6, E8);
SetIndexStyle(0, DRAW_LINE,1,2);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
SetIndexStyle(3, DRAW_LINE);
SetIndexStyle(4, DRAW_LINE);
SetIndexStyle(5, DRAW_LINE);
SetIndexStyle(6, DRAW_LINE);
Comment("www.eazhijia.com");
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[])
{
int cnt=0;
int begin_bar=0;
int prev_day, cur_day;
double day_high=0;
double day_low=0;
double yesterday_high=0;
double yesterday_low=0;
double yesterday_close=0;
double P, S, R, P1, P2, P3, C1, C2, C3;
if (Period() >= PERIOD_D1) {
Comment("WARNING: Invalid timeframe! Valid value < D1.");
return(0);
}
if (how_long == -1) {
begin_bar = Bars;
} else {
begin_bar = how_long;
}
for (cnt = begin_bar; cnt >= 0; cnt--) {
cur_day = TimeDay(Time);
if (prev_day != cur_day) {
yesterday_close = Close;
yesterday_high = day_high;
yesterday_low = day_low;
P = (yesterday_high + yesterday_low + yesterday_close) / 3;
R = yesterday_high;
S = yesterday_low;
P1 = 2 * P - S;
C1 = 2 * P - R;
P2 = P + (P1 - C1);
C2 = P - (P1 - C1);
P3 = R + (2 * (P - S));
C3 = S - (2 * (R - P));
day_high = High;
day_low = Low;
prev_day = cur_day;
}
day_high = MathMax(day_high, High);
day_low = MathMin(day_low, Low);
E2 = P;
ff = P1;
E4 = C1;
E5 = P2;
E6 = C2;
E7 = P3;
E8 = C3;
}
if (show_comment == 1) {
P = (yesterday_high + yesterday_low + yesterday_close) / 3;
R = yesterday_high;
S = yesterday_low;
P1 = 2 * P - S;
C1 = 2 * P - R;
P2 = P + (P1 - C1);
C2 = P - (P1 - C1);
P3 = R + (2 * (P - S));
C3 = S - (2 * (R - P));
Comment("Current H=", R, ", L=", S, ", HL?3=", P, " C2=", C2, ", H-L=", (R-S)/Point );
}
return(rates_total);
}
//+-----------------------------------------------------------------
支持一下:lol 前排支持下分享 学习了,不错 学习了,不错 {:1_186:} 顶下 顶下 {:1_179:} {:1_179:}
页:
[1]
2