Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
i-Moving_Average_all_TF_Real
//+------------------------------------------------------------------+
//| i-Moving_Average_all_TF_Real.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| "http://www.mql4.com/ru/users/costy_" |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link "http://www.mql4.com/ru/users/costy_"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int tf = 240;
extern int MaPeriod=14;
extern int MaMethod=0;
extern int price=0;
extern int Shift=0;
/*
iCustom(0,0,"i-Moving_Average_all_TF_Real",tf,MaPeriod,MaMethod,4,price,Shift,i);
*/
double MaBuffer[], buf_arrey[];
datetime save_time;
int i;
void init(){
ArrayResize(buf_arrey,MaPeriod*10);
ArraySetAsSeries(buf_arrey,true);
if(tf<Period())tf=Period();
switch(MaMethod){
case 0: string short_name="SMA("+TF()+", MaPeriod="+MaPeriod+")"; break;
case 1: short_name="EMA("+TF()+", MaPeriod="+MaPeriod+")"; break;
case 2: short_name="SMMA("+TF()+", MaPeriod="+MaPeriod+")"; break;
case 3: short_name="LWMA("+TF()+", MaPeriod="+MaPeriod+")"; break;
default : short_name="XHA"; Alert("Ïðîâåðüòå ïðàâèëüíîñòü ââîäà ìåòîäà ÌÀ");
}
if(MaPeriod<2) Alert("Ïðîâåðüòå ïðàâèëüíîñòü ââîäà MaPeriod");
IndicatorShortName(short_name);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MaBuffer);
SetIndexShift(0,Shift);
SetIndexLabel(0,short_name);
if(MaPeriod<2)MaPeriod=2;
}
//+------------------------------------------------------------------+
void start(){
for(i=Bars-IndicatorCounted(); i>=0; i--){
if(save_time!=iTime(0,tf, iBarShift(0,tf,Time[i]))){
save_time =iTime(0,tf, iBarShift(0,tf,Time[i]));
for(int j=MaPeriod*10-1;j>0;j--)
buf_arrey[j]=iMA(0,tf,1,0,0,price,j+iBarShift(0,tf,Time[i]));
}
buf_arrey[0]=Price(price);
MaBuffer[i]=iMAOnArray(buf_arrey,0,MaPeriod,0,MaMethod,0);
}
}
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// ôóíêöèÿ double Price(price);
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
double Price(int price){
switch(price){
case 0 : return (Close[i]);
case 1 : return (iMA(0,tf,1,0,0,1,iBarShift(0,tf,Time[i])));
case 2 : int kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i;
if(kol_vo_pois==0) return ( High[i]);
return ( High[iHighest(0,0,MODE_HIGH,kol_vo_pois,i)]);
case 3 : kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i;
if(kol_vo_pois==0) return ( Low[i]);
return ( Low[iLowest(0,0,MODE_LOW,kol_vo_pois,i)]);
case 4 : kol_vo_pois=iBarShift(0,0,iTime(0,tf, iBarShift(0,tf,Time[i])))-i;
if(kol_vo_pois==0) return ( (High[i]+Low[i])/2);
return ( (High[iHighest(0,0,MODE_HIGH,kol_vo_pois,i)]+Low[iLowest(0,0,MODE_LOW,kol_vo_pois,i)])/2);
case 5 : Print("Price not valide"); Comment("Price not valide"); return(0);
case 6 : Print("Price not valide"); Comment("Price not valide"); return(0);
}
}
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// ôóíêöèÿ string TF();
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
string TF(){
switch(tf) {
case 1 : return("M1"); case 5 : return("M5"); case 15 : return("M15");
case 30 : return("M30"); case 60 : return("H1"); case 240 : return("H4");
case 1440 : return("D1"); case 10080 : return("W1"); case 43200 : return("MN1");
default : return("Current");
}
}
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
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
---