//+------------------------------------------------------------------+ //| Delta MA.mq4 | //| Me | //| | //+------------------------------------------------------------------+ #property copyright "Me" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Yellow #property indicator_color4 Violet //---- input parameters extern int period=18; //---- buffers double UPPER[]; double LOWER[]; double MID[]; double MA[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,UPPER); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,LOWER); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,MID); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,MA); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- int i,limit; if (counted_bars<1) limit = Bars - period; else limit = Bars - counted_bars + 1; for (i=limit;i>=0;i--) { MA[i] = iMA(0,0,period,0,MODE_SMA,PRICE_CLOSE,i); // if MA is sloping up, we'll need a trigger below if (MA[i]>=MA[i+1]) { LOWER[i] = Close[i+period]; } if (MA[i]<=MA[i+1]) { UPPER[i] = Close[i+period]; } // put some yellow paint to fill the gaps, and make a smooth line if ((MA[i]>=MA[i+1] && MA[i+1]<=MA[i+2]) || (MA[i]<=MA[i+1] && MA[i+1]>=MA[i+2])) { MID[i]=Close[i+period]; MID[i+1] = Close[i+1+period]; } } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for 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: