Miscellaneous
0
Views
0
Downloads
0
Favorites
MTF_AMA
//+------------------------------------------------------------------+
//| MTF_AMA AMA.mq4 |
//| 2007 forexTSD.com | Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by konKop,wellx"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Maroon
#property indicator_color2 DodgerBlue
#property indicator_color3 DarkGoldenrod
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
//---- input parameters
extern int TimeFrame = 240;
extern int periodAMA=9;
extern int nfast=2;
extern int nslow=30;
extern double G=2.0;
extern double dK=2.0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,158);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,158);
//SetIndexDrawBegin(0,nslow+nfast);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexLabel(0,"MTF_AMA["+TimeFrame+"]("+periodAMA+")("+nfast+","+nslow+","+G+")");
SetIndexLabel(1,"MTF_AMAupSig");
SetIndexLabel(2,"MTF_AMAdnSig");
// IndicatorDigits(4);
//slowSC=0.064516;
//fastSC=0.2;
//cbars=IndicatorCounted();
//----
// return(0);
// }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
//---- name for DataWindow and indicator subwindow label
switch(TimeFrame)
{
case 1 : string TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe";
}
IndicatorShortName("MTF_AMA["+TimeFrameStr+"]("+periodAMA+")("+nfast+","+nslow+","+G+","+dK+")");
}
//---- initialization done
return(0);
//+------------------------------------------------------------------+
//| Calculations |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,shift,limit,y=0,counted_bars=IndicatorCounted();
// Plot defined timeframe on to current timeframe
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
limit=Bars-counted_bars+TimeFrame/Period();
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
//---- main loop
ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"AMA",periodAMA,nfast,nslow,G,dK,0,y);
ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"AMA",periodAMA,nfast,nslow,G,dK,1,y);
ExtMapBuffer3[i]=iCustom(NULL,TimeFrame,"AMA",periodAMA,nfast,nslow,G,dK,2,y);
}
// Refresh buffers
//++++++++++++++++++++++++++++++++++++++ upgrade by Raff
if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
/********************************************************
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
ExtMapBuffer1[i]=ExtMapBuffer1[0];
ExtMapBuffer2[i]=ExtMapBuffer2[0];
ExtMapBuffer3[i]=ExtMapBuffer3[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++ Raff
//-----
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
---