-wmmm-twoPoleSuperSmooth

Author: zzuegg
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
-wmmm-twoPoleSuperSmooth
//+------------------------------------------------------------------+
//|                                     -wmmm-twoPoleSuperSmooth.mq4 |
//|                                                           zzuegg |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "zzuegg"
#property link      "when-money-makes-money.com"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Red
//---- buffers
double filter[];
double up[];
double do[];

extern int CutoffPeriod=15; // Indicator period
extern int Shift=0; 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

double coef1,coef2,coef3,coef4;
color lc[]={Yellow,Gold,Orange,DarkOrange,OrangeRed,Red,OrangeRed,DarkOrange,Orange,Gold};
int init()
  {
  
     ObjectCreate("logo",OBJ_LABEL,0,0,0);
   ObjectSetText("logo","when-money-makes-money.com",20);
   ObjectSet("logo",OBJPROP_XDISTANCE,0);
   ObjectSet("logo",OBJPROP_YDISTANCE,30);
  
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,filter);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,up);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,do);
   SetIndexEmptyValue(0,0);
//----

   double tempReal= MathArctan(1.0);
   double rad2Deg = 45.0 / tempReal;
   double deg2Rad = 1.0 / rad2Deg;
   double pi = MathArctan(1.0) * 4.0;
   double a1 = MathExp(-MathSqrt(2.0) * pi / CutoffPeriod);
   double b1 = 2 * a1 * MathCos(deg2Rad * MathSqrt(2.0) * 180 / CutoffPeriod);
   coef2 = b1;
   coef3 = -a1 * a1;
   coef1 = 1.0 - coef2 - coef3;

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("logo");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
  
       static int currc=0;
   ObjectSet("logo",OBJPROP_COLOR,lc[currc]);
   currc++;
   if(currc>=ArraySize(lc))currc=0;
  
   int    counted_bars=IndicatorCounted();
//----
   for(int i=Bars-counted_bars-1;i>=0;i--){
      if(i<Bars-3){
         filter[i]=coef1 * ((High[i]+Low[i]) /2) + coef2 * filter[i+1] + coef3 * filter[i+1];
      }else{
         filter[i]=((High[i]+Low[i]) /2);
      }
      if(filter[i]>filter[i+1]){
         up[i]=filter[i];
         up[i+1]=filter[i+1];
      }else{
         do[i]=filter[i];
         do[i+1]=filter[i+1];
      }
   }
//----
   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 ---