0
Views
0
Downloads
0
Favorites
#MTF NMO
//+------------------------------------------------------------------+
//| #MTF_NMA.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
// MTF version coded by Chrisstoff
// Using Keris2112, CodersGuru, Raff and Igorad codes
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_buffers 4
#property indicator_separate_window
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Green
#property indicator_color4 Yellow
extern int TimeFrame=60;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle (0,DRAW_LINE);
SetIndexStyle (1,DRAW_LINE);
SetIndexStyle (2,DRAW_LINE);
SetIndexStyle (3, DRAW_LINE);
SetIndexBuffer (0, ExtMapBuffer1);
SetIndexBuffer (1, ExtMapBuffer2);
SetIndexBuffer (2, ExtMapBuffer3);
SetIndexBuffer (3, ExtMapBuffer4);
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";
}
string short_name = "MTF NMA";
IndicatorShortName (short_name+" "+TimeFrameStr);
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
// Plot defined time frame on to current time frame
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]=iCustom(NULL,TimeFrame,"NMA3",0,y);
ExtMapBuffer2[i]=iCustom(NULL,TimeFrame,"NMA3",1,y);
ExtMapBuffer3[i]=iCustom(NULL,TimeFrame,"NMA3",2,y);
ExtMapBuffer4[i]=iCustom(NULL,TimeFrame,"NMA3",3,y);
}
//----
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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]) {
//----
/************************************************ by Raff
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
ExtMapBuffer1[i]=ExtMapBuffer1[0];
ExtMapBuffer2[i]=ExtMapBuffer2[0];
ExtMapBuffer3[i]=ExtMapBuffer3[0];
ExtMapBuffer4[i]=ExtMapBuffer4[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//----
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
---