OverTrend-OSC_v1

Author: when-money-makes-money.com
Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
OverTrend-OSC_v1
//+------------------------------------------------------------------+
//|                                                    Overtrend_mq4 |
//|                                       when-money-makes-money.com |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "when-money-makes-money.com"
#property link      "when-money-makes-money.com"

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Black
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 DeepSkyBlue
#property indicator_color6 Coral
//---- buffers
double trend[];
double ExtMapBuffer2[];
double sig_up[];
double sig_do[];
double trend_up[];
double trend_do[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,5);
   SetIndexBuffer(0,trend);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(2,sig_up);
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(3,sig_do);
   SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(4,trend_up);
   SetIndexStyle(5,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(5,trend_do);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int p[]={5,14,28,32,60,102,162,264,326};
int start()
  {
   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+1;

//----
   double tmp=0;
   for(int i=limit;i>=0;i--){
      tmp=0;
      for(int j=0;j<ArraySize(p);j++){
         tmp=tmp+iCCI(Symbol(),Period(),p[j],PRICE_CLOSE,i);
      }
      trend[i]=tmp;
      if(trend[i]>0){
         if(trend[i]>trend[i+1]){
            sig_do[i]=0;
            sig_up[i]=trend[i];
            trend_do[i]=0;
            trend_up[i]=0; 
         }else{
            trend_do[i]=0;
            trend_up[i]=trend[i];         
            sig_up[i]=0;
            sig_do[i]=0;  
         }
      }else{
         if(trend[i]<trend[i+1]){
            sig_up[i]=0;
            sig_do[i]=trend[i];  
            trend_do[i]=0;
            trend_up[i]=0;                    
         }else{
            trend_up[i]=0;
            trend_do[i]=trend[i]; 
            sig_up[i]=0;
            sig_do[i]=0;                    
         }      
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

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 ---