Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
J2_MA
//+------------------------------------------------------------------+
//| J2_MA.mq4 |
//| Copyright © 2011,Dodonov Vitalii |
//| ellizii@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011,Dodonov Vitalii"
#property link "ellizii@mail.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//--- input parameters
extern int period=6;
extern int method=3;
//--- buffers
double ExtMapBuffer1[];
double mass1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,mass1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),i=Bars-counted_bars-1;
int periodf=Period();
int tme=big_time(periodf);
int ry=time(periodf);
if(periodf<=0){Alert("Íåâîçìîæíî ïðîèçâåñòè ðàñ÷åò");return(0);}
J2(tme/periodf,ry/periodf,tme/periodf,mass1);
for(int t=0;t<=Bars-1;t++){
//----
if(period>1){ExtMapBuffer1[t]=iMAOnArray(mass1,0,period,0,method,t);}else{ExtMapBuffer1[t]=mass1[t];}
//----
}
//Alert(mass1[2]);
return(0);
}
//+------------------------------------------------------------------+
int big_time(int period){
int pr;
if(period==1) pr=PERIOD_M15;
if(period==5) pr=PERIOD_H1;
if(period==15)pr=PERIOD_H4;
if(period==30) pr=PERIOD_D1;
if(period==60) pr=PERIOD_D1;
if(period==240) pr=PERIOD_W1;
if(period==1440) pr=PERIOD_MN1;
if(period==10080) pr=PERIOD_MN1;
if(period==43200) pr=-1;
return(pr);
}
int time(int period){
int pr;
if(period==1) pr=PERIOD_M5;
if(period==5) pr=PERIOD_M15;
if(period==15)pr=PERIOD_M30;
if(period==30) pr=PERIOD_H1;
if(period==60) pr=PERIOD_H4;
if(period==240) pr=PERIOD_D1;
if(period==1440) pr=PERIOD_W1;
if(period==10080) pr=PERIOD_MN1;
if(period==43200) pr=-1;
return(pr);
}
void J2(int period1,int period2, int period3,double &mass[]){
int y=Bars-IndicatorCounted()-1;
while(y>=0){
double ma1=0,ma2=0,ma3=0;
ma1=iMA(NULL,0,period1,0,MODE_LWMA,6,y);
ma2=iMA(NULL,0,period2,0,MODE_EMA,6,y);
ma3=iMA(NULL,0,period3,0,MODE_LWMA,6,y);
mass[y]=0.0;
mass[y]=(2*ma2+((ma3+ma2)/2-ma1))/2;
y--;
}
}
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
---