//+------------------------------------------------------------------+ //| RollerCoaster.mq4 | //| Copyright © 2008, Vishal | //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, Vishal" #property link "" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Silver #property indicator_color2 DodgerBlue #property indicator_color3 Crimson //---- input parameters extern int MAperiod=21; extern string Note_MAmethod="0=sma 1=ema 2=smma 3=lwma"; extern int MAmethod=0; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE,STYLE_DOT); SetIndexBuffer(2,ExtMapBuffer3); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); counted_bars--; int i, startbar, hh, ll; double mavrg; startbar = Bars - counted_bars - MAperiod; for (i=startbar; i>=0; i--) { mavrg = iMA(NULL,0,MAperiod,0,MAmethod,PRICE_CLOSE,i); ExtMapBuffer1[i] = mavrg; if (High[i+2]==High[iHighest(NULL,0,MODE_HIGH,5,i)]) { for (int j=i+2;j>=i;j--) ExtMapBuffer2[j]=High[i+2]; } else ExtMapBuffer2[i] = ExtMapBuffer2[i+1]; if (Low[i+2]==Low[iLowest(NULL,0,MODE_LOW,5,i)]) { for (int k=i+2;k>=i;k--) ExtMapBuffer3[k]=Low[i+2]; } else ExtMapBuffer3[i] = ExtMapBuffer3[i+1]; } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: