Author: Copyright � 2009, Ivan Kornilov. All rights reserved.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
AOC2P4N3
//+------------------------------------------------------------------+
//|                                   Copyright © 2010, Ivan Kornilov|
//|                                                       AOCP4N3.mq4|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Ivan Kornilov. All rights reserved."
#property link "excelf@gmail.com"

#property indicator_separate_window 
#property indicator_buffers 2
#property indicator_color1 DarkOliveGreen 
#property indicator_color2 LightCoral    

extern int periodMa=5;
extern int step=8;
extern double speedSens= 1.3;
extern int noiseFilter = 0;

double line[];
double green[];
double red[];
double acceleration[];
double aoc2[];
double ma[];

int step2;
int step3;
int step4;
int step5;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(6);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);

   SetIndexBuffer(0,green);
   SetIndexBuffer(1,red);

   SetIndexBuffer(2,acceleration);
   SetIndexBuffer(3,ma);
   SetIndexBuffer(4,line);
   SetIndexBuffer(5,aoc2);

   IndicatorDigits(Digits+3);

   SetIndexDrawBegin(0,periodMa*2);
   SetIndexDrawBegin(1,periodMa*2);

   step2 =  step  *  speedSens;
   step3 =  step2 *  speedSens;
   step4 =  step3 *  speedSens;
   step5 =  step4 *  speedSens;

   IndicatorShortName("AOC2P4N3("+periodMa+","+step+","+DoubleToStr(speedSens,2)+","+noiseFilter+")");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int n;
   int i;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+MathMax(step,MathMax(MathMax(step2,step3),MathMax(step4,step5)));

   i=limit;
   while(i>=0)
     {
      ma[i]=iMA(NULL,0,periodMa,0,MODE_LWMA,PRICE_TYPICAL,i)/Point;
      line[i]=(5*ma[i]-(ma[i+step]+ma[i+step2]+ma[i+step3]+ma[i+step4]+ma[i+step5]))/5;
      acceleration[i]=(5*line[i]-(line[i+step]+line[i+step2]+line[i+step3]+line[i+step4]+line[i+step5]))/5;
      aoc2[i]=(5*acceleration[i]-(acceleration[i+step]+acceleration[i+step2]+acceleration[i+step3]+acceleration[i+step4]+acceleration[i+step5]))/5;
      i--;
     }

//   i=Bars-IndicatorCounted();
   i=limit;
   while(i>=0)
     {
      double slowingEMA=iMAOnArray(aoc2,Bars,noiseFilter,0,MODE_LWMA,i);
      if(
         slowingEMA>aoc2[i]
         )
        {
         red[i]=aoc2[i];
         green[i]=EMPTY_VALUE;
           } else {
         red[i]=EMPTY_VALUE;
         green[i]=aoc2[i];
        }
      i--;
     }
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---