MAadaptive (rsi)

Author: copyleft mladen
Indicators Used
Moving average indicatorRelative strength index
0 Views
0 Downloads
0 Favorites
MAadaptive (rsi)
//+------------------------------------------------------------------+
//|                                             MAadaptive (rsi).mq4 |
//|                                                                  |
//| based on MA adaptive RSI by Perry Kaufman                        |
//+------------------------------------------------------------------+
#property copyright "copyleft mladen"
#property link      "mladenfx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

//
//
//
//
//

extern int       MA.period = 20;
extern int       MA.price  = PRICE_CLOSE;

//
//
//
//
//

double buffer[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,buffer);
   return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int      countedBars=IndicatorCounted();
   int      i,limit;

   if (countedBars<0) return(-1);
   if (countedBars>0) countedBars--;
         limit = Bars-countedBars;

   //
   //
   //
   //
   //

      
   for(i = limit; i >=0; i--)
   {
      double price = iMA(NULL,0,1,0,MODE_SMA,MA.price,i);
         if (i>Bars-MA.period)
         {
            buffer[i]=price; continue;
         }
      
      //
      //
      //
      //
      //
      
      double sc = 2.0*MathAbs(iRSI(NULL,0,MA.period,MA.price,i)/100.0-0.5);
      buffer[i] = buffer[i+1] +sc*(price-buffer[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 ---