Price Data Components
0
Views
0
Downloads
0
Favorites
All S&R
//+------------------------------------------------------------------+
//| 3 S & R.mq4 |
//| Copyright © 2006 |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006"
#property link ""
#property indicator_chart_window
//---- input parameters
extern int DD=4;//--- decimal places
//---- buffers
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//---- Objects
double R1,R2,R3,S1,S2,S3;
R1 = iHigh(NULL,PERIOD_MN1,1);
R2 = iHigh(NULL,PERIOD_W1,1);
R3 = iHigh(NULL,PERIOD_D1,1);
S1 = iLow(NULL,PERIOD_MN1,1);
S2 = iLow(NULL,PERIOD_W1,1);
S3 = iLow(NULL,PERIOD_D1,1);
ObjectCreate("MR",OBJ_HLINE,0,0,R1);
ObjectSet("MR",OBJPROP_COLOR,Yellow);
ObjectSet("MR",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("WR",OBJ_HLINE,0,0,R2);
ObjectSet("WR",OBJPROP_COLOR,SpringGreen);
ObjectSet("WR",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("DR",OBJ_HLINE,0,0,R3);
ObjectSet("DR",OBJPROP_COLOR,Tan);
ObjectSet("DR",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("MS",OBJ_HLINE,0,0,S1);
ObjectSet("MS",OBJPROP_COLOR,Yellow);
ObjectSet("MS",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("WS",OBJ_HLINE,0,0,S2);
ObjectSet("WS",OBJPROP_COLOR,SpringGreen);
ObjectSet("WS",OBJPROP_STYLE,STYLE_SOLID);
ObjectCreate("DS",OBJ_HLINE,0,0,S3);
ObjectSet("DS",OBJPROP_COLOR,Tan);
ObjectSet("DS",OBJPROP_STYLE,STYLE_SOLID);
ObjectsRedraw();
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double R1,R2,R3,S1,S2,S3,rg1,rg2,rg3,fx,bcl,bch,bc,sch,scl,sc;
int rg1a,rg2a,rg3a;
if(DD==2)
{
fx=100;
}
else
{
fx=10000;
}
R1 = iHigh(NULL,PERIOD_MN1,1);
R2 = iHigh(NULL,PERIOD_W1,1);
R3 = iHigh(NULL,PERIOD_D1,1);
S1 = iLow(NULL,PERIOD_MN1,1);
S2 = iLow(NULL,PERIOD_W1,1);
S3 = iLow(NULL,PERIOD_D1,1);
rg1=(R1-S1)*fx;
rg2=(R2-S2)*fx;
rg3=(R3-S3)*fx;
rg1a=MathRound(rg1);
rg2a=MathRound(rg2);
rg3a=MathRound(rg3);
string R1a=DoubleToStr(R1,DD);
string R2a=DoubleToStr(R2,DD);
string R3a=DoubleToStr(R3,DD);
string S1a=DoubleToStr(S1,DD);
string S2a=DoubleToStr(S2,DD);
string S3a=DoubleToStr(S3,DD);
drawLabel("RL","MR: "+R1a+" WR: "+R2a+" DR: "+R3a,12,SkyBlue,5,35,"Arial Narrow");
drawLabel("SRR","MRg: "+rg1a+" pips WRg: "+rg2a+" pips DRg: "+rg3a+" pips",10,SpringGreen,5,20,"Arial Narrow");
drawLabel("SL","MS: "+S1a+" WS: "+S2a+" DS: "+S3a,12,Tan,5,5,"Arial Narrow");
ObjectsRedraw();
//----
return(0);
}
//+------------------------------------------------------------------+
void drawLabel(string id, string text,int fsize, color fcolor,int x,int y,string font="Arial Narrow",int window = 0)
{ if(ObjectFind(id)==-1)
{
ObjectCreate(id, OBJ_LABEL, window, 0, 0);
ObjectSetText(id,text, fsize, font, fcolor);
ObjectSet(id, OBJPROP_CORNER, 2);
ObjectSet(id, OBJPROP_XDISTANCE, x);
ObjectSet(id, OBJPROP_YDISTANCE, 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
---