Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
W%R_MA_LC
//+------------------------------------------------------------------+
//| W%R_MA_LC.mq4
//+------------------------------------------------------------------+
#property copyright "AHGduP"
#property link "W%R_MA_LC"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Chartreuse
#property indicator_width1 2
#property indicator_color2 Red//DodgerBlue
#property indicator_width2 2
//#property indicator_minimum 0
//#property indicator_maximum 100
//=========================================================================
#property indicator_level1 100
#property indicator_level2 85
//#property indicator_level3 80
#property indicator_level4 50
//#property indicator_level5 20
#property indicator_level6 15
#property indicator_level7 0
#property indicator_levelcolor SlateGray //C'160,160,160' //DarkGray
#property indicator_levelstyle STYLE_DOT
#property indicator_levelwidth 1
//==========================================================================
extern int WPR_Per = 16;
extern int MA_Per = 8 ;
extern int LineSize1 = 2;
extern int LineSize2 = 2;
extern int CountBars = 400;
double wpr_Buffer1[];
double wpr_Buffer2[];
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void init() {
IndicatorDigits(+1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,LineSize1);
SetIndexBuffer(0,wpr_Buffer1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,LineSize2);
SetIndexBuffer(1,wpr_Buffer2);
//+------------------------------------------------------------------+
string ThisName = "WPR_MA_LC";
string Text=ThisName;
Text=Text+"(";
Text=Text+" "+DoubleToStr(WPR_Per,0);
Text=Text+", "+DoubleToStr(MA_Per,0);
Text=Text+") ";
IndicatorShortName("WPR_MA_LC");
SetIndexLabel(0,"WPR_MA_LC");
//+------------------------------------------------------------------+
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{ Refresh();
return(0);
}
//=====================================================================
void start()
{ Refresh();
draw_wpr(1,wpr_Buffer1,wpr_Buffer2);
draw_wpr(2,wpr_Buffer1,wpr_Buffer2);
}
//+--------------------------------------------------------
void draw_wpr(int buf_num,double &b1[],double &b2[]){
int LoopBegin;
if (CountBars==0) LoopBegin=Bars-1;
else LoopBegin=CountBars-1;
int limit=Bars-CountBars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
int numinput = WPR_Per;
if(buf_num==2)
{ numinput = MA_Per;
}
int i,y=0;
double min=0,max=-100;
for(i=0,y=0;i<LoopBegin;i++){
b1[i]=iWPR(NULL,0,WPR_Per,i);
while(limit>0)
{
double sum=0,ma= 0;
for(int j=0;j<MA_Per;j++)
{ sum = sum + iWPR(NULL,0,WPR_Per,limit+j);}
ma = sum / MA_Per;
//----
b2[limit-1] = ma;
// Comment(ma);
limit--;
}
min = MathMin(min,MathMin(b1[i],b2[i]));
max = MathMax(max,MathMax(b1[i],b2[i]));
}
min = MathAbs(min);
max = max + min;
for(i=0;i<LoopBegin;i++)
{
b1[i] = 100 * ( b1[i] + min )/max;
b2[i] = 100 * ( b2[i] + min )/max;
}
//========================LABEL========================================================================================
{ ObjectCreate ("wprlc_lab", OBJ_LABEL,WindowFind("WPR_MA_LC"), 0, 0);
if ( b1[0] > b2[0] ){ ObjectSetText("wprlc_lab", "WPR= "+DoubleToStr(b1[0],1)+"", 12, "Tahoma Bold", Lime);}
if ( b1[0] < b2[0] ){ ObjectSetText("wprlc_lab", "WPR= "+DoubleToStr(b1[0],1)+"", 12, "Tahoma Bold", Red);}
ObjectSet ("wprlc_lab", OBJPROP_XDISTANCE, 1150);
ObjectSet ("wprlc_lab", OBJPROP_YDISTANCE, 70);
}
}
//=====================================================================================================================
void Refresh()
{
ObjectDelete("wprlc_lab");
}
//--------------------------------------------------------------------------------------------------------------------+
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
---