Miscellaneous
0
Views
0
Downloads
0
Favorites
i-AMA-Optimum
//+--------------------------------------------------------------------------------------+
// A M A O P T I M U M |
// Copyright © RickD BJF Trading Group 2006 |
// http://fxstrategy.ca |
// |
//Experts http://fxstrategy.ca/experts.php SALE! 50% OFF |
//Indicators http://fxstrategy.ca/products.php SALE!50% OFF |
//Digital Filters Strategy http://fxstrategy.ca/digital_filtrs.php SALE!50% OFF |
//Trading Signals http://fxstrategy.ca/signals.php Two weeks FREE! No CC. |
// forex calendar, research, article .... |
//+--------------------------------------------------------------------------------------+
#property copyright "© RickD BJF Trading Group 2006"
#property link "http://fxstrategy.ca/products.php"
//----
#define major 1
#define minor 0
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Orange
#property indicator_color2 Black
#property indicator_width1 2
//---- indicator parameters
extern int P = 1000;
extern double Fast = 2;
extern double Slow = 10;
//---- indicator buffers
double buf1[];
double buf2[];
//----
double SlowSC, FastSC;
double AMA;
double Noise, Signal;
double ER, SSC;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//---- âû÷èñëÿåì ñãëàæèâàþùèå êîíñòàíòû
SlowSC = 2 / (1 + Slow);
FastSC = 2 / (1 + Fast);
//----
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 158);
// IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1);
SetIndexBuffer(0, buf1);
SetIndexBuffer(1, buf2);
//----
SetIndexEmptyValue(0, 0.0);
SetIndexEmptyValue(1, 0.0);
//----
IndicatorShortName("AMA("+ P + ", " + Fast + ", " + Slow + ")");
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if(Bars < P)
return (0);
int counted = IndicatorCounted();
// if(Symbol() == "EURUSD")
// Print("C= ", counted, " B= ", Bars);
if(counted < 0)
return (-1);
if(counted == Bars-1)
return (0);
int limit = 0;
if(counted == 0 || counted > Bars-2)
{
Noise = 0;
limit = Bars - 2;
}
//----
for(int i = limit; i >= 0; i--)
{
if(limit > 0 && i > limit - P)
{
Noise += MathAbs(Open[i] - Open[i+1]);
buf1[i] = 0;
buf2[i] = 0;
continue;
}
Signal = MathAbs(Open[i] - Open[i+P]);
Noise += MathAbs(Open[i] - Open[i+1]);
Noise -= MathAbs(Open[i+P] - Open[i+1+P]);
//----
ER = 1;
if(Noise > 0)
ER = Signal / Noise;
SSC = MathPow(SlowSC + ER*(FastSC - SlowSC), 2);
//----
if(i == limit - P)
AMA = Open[i];
else
AMA = SSC*Open[i] + (1 - SSC)*buf1[i+1];
buf1[i] = AMA;
buf2[i] = AMA;
}
return (0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---