Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
MA_xtf
//+---------------------------------------------------------------------+
//| MovingAverage xtf |
//+---------------------------------------------------------------------+
//mod 2008fxtsd ki
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
extern int TimeFrame =0;
extern int ma_period =34;
extern int ma_method =1;
extern int ma_price =PRICE_CLOSE;
extern int ma_shift =0;
extern string note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string MA_Method_ = "SMA0 EMA1 SMMA2 LWMA3";
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN;0-currentTF";
double Buffer1[];
double period;
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,Buffer1);
SetIndexStyle( 0,DRAW_LINE);
if(TimeFrame==0) TimeFrame = Period();
SetIndexShift(0,ma_shift*TimeFrame/Period());
//----
string name;
switch(ma_method)
{
case 1 : name=" EMA "; break;
case 2 : name=" SMMA "; break;
case 3 : name=" LWMA "; break;
default : name=" SMA ";
}
//--
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1"; break;
case 5 : TimeFrameStr="M5"; break;
case 15 : TimeFrameStr="M15"; break;
case 30 : TimeFrameStr="M30"; break;
case 60 : TimeFrameStr="H1"; break;
case 240 : TimeFrameStr="H4"; break;
case 1440 : TimeFrameStr="D1"; break;
case 10080 : TimeFrameStr="W1"; break;
case 43200 : TimeFrameStr="MN"; break;
}
string shortname;
shortname= name+ " ("+ma_period+") "+TimeFrameStr +" ["+TimeFrame/Period()+","+ma_period*TimeFrame/Period()+"] ";
IndicatorShortName(shortname);
SetIndexLabel(0,shortname);
}
return(0);
//+------------------------------------------------------------------+
int start()
{
int i,limit, counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=limit; i>=0; i--)
{
if (TimeFrame ==0) TimeFrame = Period();
period= ma_period*TimeFrame/Period();
Buffer1[i]=iMA(NULL,0,period,0,ma_method,ma_price,i) ;
}
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
---