Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
MTF_EnvelopesM1
//+------------------------------------------------------------------+
//| MTF_EnvelopesMM.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| www.forex-tsd.com http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 FireBrick
//---- indicator parameters
extern int TimeFrame=0;
extern int MA_Period=34;
extern int MA_Shift=0;
extern int MA_Method=0;
extern int Applied_Price=0;
extern double Deviation=0.1;
//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
string short_name;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
if(TimeFrame==0) TimeFrame = Period();
SetIndexShift(0,MA_Shift*TimeFrame/Period());
SetIndexShift(1,MA_Shift*TimeFrame/Period());
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
// if(MA_Period<2) MA_Period=14;
draw_begin=MA_Period-1;
//---- indicator short name
SetIndexLabel(0,"MTF_Env("+MA_Period+")Upper,TF"+TimeFrame+"");
SetIndexLabel(1,"MTF_Env("+MA_Period+")Lower,TF"+TimeFrame+"");
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
// if(Deviation<0.1) Deviation=0.1;
// if(Deviation>100.0) Deviation=100.0;
IndicatorShortName("MTF_Env("+MA_Period+"),TF"+TimeFrame+"");
//---- 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";
}
}
//---- initialization done
return(0);
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
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++;
ExtMapBuffer1[i] = (1+Deviation/100)*iMA(NULL,TimeFrame,MA_Period,0,MA_Method,Applied_Price,y);
ExtMapBuffer2[i] = (1-Deviation/100)*iMA(NULL,TimeFrame,MA_Period,0,MA_Method,Applied_Price,y);
}
//---- Refresh buffers +++++++++++++++++++++++++++++++ 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];
*************************************** upgrade by Raff ***/
ExtMapBuffer1[i]=ExtMapBuffer1[0];
ExtMapBuffer2[i]=ExtMapBuffer2[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//---- done
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
---