Joined: Tue Jun 23, 2009 2:46 pm Posts: 5
|
- //+------------------------------------------------------------------+
- //| MultiTimeFrameCCI.mq5 |
- //| Copyright 2010, Investeo.pl |
- //| http:Investeo.pl |
- //+------------------------------------------------------------------+
- #property copyright "2010, Investeo.pl"
- #property link "http://Investeo.pl"
- #property version "1.00"
- #property indicator_separate_window
-
- #property indicator_buffers 3
- #property indicator_plots 3
-
- #property indicator_color1 Red
- #property indicator_color2 Green
- #property indicator_color3 DarkSalmon
-
- #property indicator_type1 DRAW_LINE
- #property indicator_type2 DRAW_LINE
- #property indicator_type3 DRAW_LINE
-
- #property indicator_width1 1
- #property indicator_width2 1
- #property indicator_width3 1
-
- #property indicator_level1 -100.0
- #property indicator_level2 100.0
-
- double vals_m1[];
- double vals_m2[];
- double vals_m3[];
-
- int hCCI_m1, hCCI_m2, hCCI_m3;
- int ctx;
-
- input int CCIPeriod = 14;
- input ENUM_APPLIED_PRICE AppliedPrice = PRICE_TYPICAL;
-
-
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //--- indicator buffers mapping
- SetIndexBuffer(0, vals_m1, INDICATOR_DATA);
- SetIndexBuffer(1, vals_m2, INDICATOR_DATA);
- SetIndexBuffer(2, vals_m3, INDICATOR_DATA);
-
- PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,CCIPeriod);
- PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,CCIPeriod);
- PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,CCIPeriod);
-
- hCCI_m1 = iCCI(NULL, PERIOD_M1, CCIPeriod, AppliedPrice);
- hCCI_m2 = iCCI(NULL, PERIOD_M2, CCIPeriod, AppliedPrice);
- hCCI_m3 = iCCI(NULL, PERIOD_M3, CCIPeriod, AppliedPrice);
-
- //---
- return(0);
- }
- //+------------------------------------------------------------------+
- //| 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[])
- {
- //---
- ctx = CopyBuffer(hCCI_m1, 0, 0, rates_total, vals_m1);
- if (ctx == -1)
- {
- Print("Error while m1 data copying. Error Number : ", GetLastError());
- return 1;
- }
- ctx = CopyBuffer(hCCI_m2, 0, 0, rates_total, vals_m2);
- if (ctx == -1)
- {
- Print("Error while m2 data copying. Error Number : ", GetLastError());
- return 1;
- }
- ctx = CopyBuffer(hCCI_m3, 0, 0, rates_total, vals_m3);
- if (ctx == -1)
- {
- Print("Error while m3 data copying. Error Number : ", GetLastError());
- return 1;
- }
-
- return(rates_total);
- }
- //+------------------------------------------------------------------+
-
|
|