CZI指标根据均线和收盘价在副图创建柱状线,不同颜色代表不同的行情。
- //+------------------------------------------------------------------+
- //| CZI.mq4 |
- //| atfxtrader |
- //+------------------------------------------------------------------+
- #property copyright "下载更多外汇EA,外汇指标,交易系统,就到【外汇EA之家】"
- #property link "http://www.eazhijia.com"
- #property strict
- #property indicator_separate_window
- #property indicator_buffers 8
- #property indicator_color1 Black
- #property indicator_color2 Black
- #property indicator_color3 Black
- #property indicator_color4 Black
- #property indicator_color5 Black
- #property indicator_color6 Black
- #property indicator_color7 Black
- #property indicator_color8 Black
- int g_period_76 = 34;
- double g_ibuf_80[];
- double g_ibuf_84[];
- double g_ibuf_88[];
- double g_ibuf_92[];
- double g_ibuf_96[];
- double g_ibuf_100[];
- double g_ibuf_104[];
- double g_ibuf_108[];
- void onInit(void)
- {
- SetIndexBuffer(0, g_ibuf_80);
- SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 3, LawnGreen);
- SetIndexBuffer(1, g_ibuf_84);
- SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 3, LimeGreen);
- SetIndexBuffer(2, g_ibuf_88);
- SetIndexStyle(2, DRAW_HISTOGRAM, EMPTY, 3, DarkGreen);
- SetIndexBuffer(3, g_ibuf_92);
- SetIndexStyle(3, DRAW_HISTOGRAM, EMPTY, 3, Aqua);
- SetIndexBuffer(4, g_ibuf_96);
- SetIndexStyle(4, DRAW_HISTOGRAM, EMPTY, 3, Gold);
- SetIndexBuffer(5, g_ibuf_100);
- SetIndexStyle(5, DRAW_HISTOGRAM, EMPTY, 3, Orange);
- SetIndexBuffer(6, g_ibuf_104);
- SetIndexStyle(6, DRAW_HISTOGRAM, EMPTY, 3, OrangeRed);
- SetIndexBuffer(7, g_ibuf_108);
- SetIndexStyle(7, DRAW_HISTOGRAM, EMPTY, 3, SaddleBrown);
- }
- 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 li_8;
- double ld_12;
- string ls_20;
- string ls_unused_28;
- double l_ima_36;
- int li_4 = IndicatorCounted();
- if (li_4 < 0) return(0);
- if (li_4 > 0) li_4--;
- li_4 = Bars - li_4;
- for (int li_0 = 0; li_0 < li_4; li_0++) {
- ls_unused_28 = TimeToStr(Time[li_0], TIME_MINUTES);
- g_ibuf_80[li_0] = 0;
- g_ibuf_84[li_0] = 0;
- g_ibuf_88[li_0] = 0;
- g_ibuf_92[li_0] = 0;
- g_ibuf_96[li_0] = 0;
- g_ibuf_100[li_0] = 0;
- g_ibuf_104[li_0] = 0;
- g_ibuf_108[li_0] = 0;
- l_ima_36 = iMA(NULL, 0, g_period_76, 0, MODE_EMA, PRICE_TYPICAL, li_0);
- if (Close[li_0] >= l_ima_36) {
- ld_12 = Close[li_0] - l_ima_36;
- li_8 = StringFind(Symbol(), "JPY", 0);
- ls_20 = StringSubstr(Symbol(), li_8, 3);
- if (ls_20 == "JPY") ld_12 /= 100.0;
- if (ld_12 < 0.0002) g_ibuf_80[li_0] = 1;
- else {
- if (ld_12 < 0.0003) g_ibuf_84[li_0] = 1;
- else {
- if (ld_12 < 0.0004) g_ibuf_88[li_0] = 1;
- else
- if (ld_12 >= 0.0004) g_ibuf_92[li_0] = 1;
- }
- }
- } else {
- if (Close[li_0] < l_ima_36) {
- ld_12 = l_ima_36 - Close[li_0];
- li_8 = StringFind(Symbol(), "JPY", 0);
- ls_20 = StringSubstr(Symbol(), li_8, 3);
- if (ls_20 == "JPY") ld_12 /= 100.0;
- if (ld_12 < 0.0002) g_ibuf_96[li_0] = 1;
- else {
- if (ld_12 < 0.0003) g_ibuf_100[li_0] = 1;
- else {
- if (ld_12 < 0.0004) g_ibuf_104[li_0] = 1;
- else
- if (ld_12 >= 0.0004) g_ibuf_108[li_0] = 1;
- }
- }
- }
- }
- }
- return (rates_total);
- }
|