Miscellaneous
0
Views
0
Downloads
0
Favorites
MTF_AMA_SLOPE_v21
//+------------------------------------------------------------------+
//| MTF_AMA_SLOPE_v2 AMA SLOPE.mq4 |
//| 2007 forexTSD.com 2006 Kalenzo |
//| bartlomiej.gorski@gmail.com |
//| I used the idea of P.Kauffman and code from KAMA idk |
//| made by © 2004, by konKop,wellx |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "bartlomiej.gorski@gmail.com"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Maroon
#property indicator_color4 DarkGreen
#property indicator_color5 Maroon
#property indicator_color6 DarkGreen
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 2
//#property indicator_level1 0.002
//---- input parameters
extern int TimeFrame = 0;
extern int periodAMA=9;
extern int nfast=2;
extern int nslow=30;
extern double G=2.0;
extern int trigger = 2;
extern color triggerPlus = Maroon;
extern color triggerMinus = DarkGreen;
//---- buffers
//double kAMAbuffer[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
//+------------------------------------------------------------------+
//int cbars=0, prevbars=0, prevtime=0;
//double slowSC,fastSC;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,"AMA_Sl2["+TimeFrame+"]("+periodAMA+")("+nfast+","+nslow+")");
//---- indicators
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexBuffer(3,ExtMapBuffer4);
// drawLine((trigger*Point),"Trigger+", triggerPlus);
// drawLine((-trigger*Point),"Trigger-", triggerMinus);
//SetLevelValue(0,(trigger*Point));
//SetLevelValue(1,(-trigger*Point));
//SetLevelStyle(0,0,triggerPlus);
//SetLevelStyle(1,0,triggerMinus);
SetIndexStyle(4,DRAW_LINE,4,0,triggerMinus);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE,4,0,triggerPlus);
SetIndexBuffer(5,ExtMapBuffer6);
// drawLine(trigger,"BuyTrigger", Red);
// drawLine(-trigger,"SellTrigger", Red);
// IndicatorDigits(4);
// IndicatorShortName("MTF_AMA_Slope_v2");
// 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_Slope2["+TimeFrameStr+"]("+periodAMA+")("+nfast+","+nslow+")");
//---- 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_SLOPE_v2",periodAMA,nfast,nslow,G, 0,y);
ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"AMA_SLOPE_v2",periodAMA,nfast,nslow,G, 1,y);
ExtMapBuffer3[i]=iCustom(NULL,TimeFrame,"AMA_SLOPE_v2",periodAMA,nfast,nslow,G, 2,y);
ExtMapBuffer4[i]=iCustom(NULL,TimeFrame,"AMA_SLOPE_v2",periodAMA,nfast,nslow,G, 3,y);
ExtMapBuffer5[i]= trigger*Point;
ExtMapBuffer6[i]= -trigger*Point;
}
// 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];
ExtMapBuffer4[i]=ExtMapBuffer4[0];
ExtMapBuffer5[i]=ExtMapBuffer5[0];
ExtMapBuffer6[i]=ExtMapBuffer6[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++ Raff
//-----
return(0);
}
//+------------------------------------------------------------------+
/*
void drawLine(double lvl,string name, color Col )
{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, WindowFind(name), Time[0], lvl,Time[0], lvl);
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
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
---