Price Data Components
0
Views
0
Downloads
0
Favorites
Pivot_ESAZ_Day_v1
//+------------------------------------------------------------------+
//| Pivot_ESAZ_Day.mq4 |
//| DimDimych |
//| http://goodservice.su/forum/25-3550-1 |
//+------------------------------------------------------------------+
#property copyright "DimDimych"
#property link "http://goodservice.su/forum/25-3550-1"
#property indicator_chart_window
//---- input parameters
extern int CountDays =1;
extern int GMT =0;
extern color pivot =Gold;
extern color day =Yellow;
extern color level_up =DodgerBlue;
extern color level_dn =Tomato;
extern color setka =Lime;
extern color metka =MidnightBlue;
//---- indicator buffers
double range[];
double ny_close[];
double low[];
double high[];
datetime time1;
datetime time2;
datetime ny_time[];
int shift, num;
int ny_shift[];
datetime prevDay=0;
bool fTime;
// ----
void ObjDel()
{
if (ObjectsTotal() > 0)
for (num=0;num<=CountDays;num++)
{
ObjectDelete("PPw["+num+"]");
ObjectDelete("R1w["+num+"]");
ObjectDelete("R2w["+num+"]");
ObjectDelete("R3w["+num+"]");
ObjectDelete("R4w["+num+"]");
ObjectDelete("S1w["+num+"]");
ObjectDelete("S2w["+num+"]");
ObjectDelete("S3w["+num+"]");
ObjectDelete("S4w["+num+"]");
ObjectDelete("GL1w["+num+"]");
ObjectDelete("GL2w["+num+"]");
ObjectDelete("GL3w["+num+"]");
ObjectDelete("GL4w["+num+"]");
ObjectDelete("GL5w["+num+"]");
ObjectDelete("GL6w["+num+"]");
ObjectDelete("GL7w["+num+"]");
ObjectDelete("GL8w["+num+"]");
ObjectDelete("GL9w["+num+"]");
ObjectDelete("GL10w["+num+"]");
ObjectDelete("GL11w["+num+"]");
ObjectDelete("GL12w["+num+"]");
ObjectDelete("GL13w["+num+"]");
ObjectDelete("GL14w["+num+"]");
ObjectDelete("GL15w["+num+"]");
ObjectDelete("GL16w["+num+"]");
ObjectDelete("pV["+num+"]");
}
ObjectDelete("mPw");
ObjectDelete("mR1w");
ObjectDelete("mR2w");
ObjectDelete("mR3w");
ObjectDelete("mR4w");
ObjectDelete("mS1w");
ObjectDelete("mS2w");
ObjectDelete("mS3w");
ObjectDelete("mS4w");
ObjectDelete("pV0");
}
// ----
void PlotLine(string name,double value,double value1,double line_color,double style)
{
double valueN=NormalizeDouble(value,Digits);
double valueN1=NormalizeDouble(value1,Digits);
bool res = ObjectCreate(name,OBJ_TREND,0,time1,valueN,time2,valueN1);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_STYLE, style);
ObjectSet(name, OBJPROP_RAY, false);
ObjectSet(name, OBJPROP_BACK, true);
ObjectSet(name, OBJPROP_COLOR, line_color);
}
//***********
void PlotVLine(string name,double tm,double line_color)
{
bool res = ObjectCreate(name,OBJ_VLINE,0,tm,0);
ObjectSet(name, OBJPROP_WIDTH, 0);
ObjectSet(name, OBJPROP_STYLE, 2);
ObjectSet(name, OBJPROP_COLOR, line_color);
}
//***********
void PlotPrice(string name, double value, double line_color)
{
double valueN=NormalizeDouble(value,Digits);
bool res = ObjectCreate(name, OBJ_ARROW, 0, time2,valueN);
ObjectSet(name, OBJPROP_COLOR, line_color);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
fTime = true;
IndicatorBuffers(2);
SetIndexBuffer(0,range);
SetIndexBuffer(1,ny_close);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjDel();
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| LNX_Pivots_v3.1 |
//+------------------------------------------------------------------+
int start()
{
int i;
double P,R1,R2,R3,R4,S1,S2,S3,S4;
datetime cDay = iTime(NULL,PERIOD_D1,0) + (GMT-Period()/60.0)*3600;
if (cDay != prevDay || fTime)
{
ObjDel();
ArrayResize(ny_time,CountDays+1);
ArrayResize(ny_shift,CountDays+1);
ArrayResize(high,CountDays+1);
ArrayResize(low,CountDays+1);
ArrayResize(range,CountDays+1);
for (shift=0;shift<=CountDays;shift++)
{
ny_time[shift] = iTime(NULL,PERIOD_D1,shift) + (GMT-Period()/60.0)*3600;
ny_shift[shift] = iBarShift(NULL,0,ny_time[shift]);
ny_close[shift] = iClose(NULL,0,ny_shift[shift]);
}
for (shift=0;shift<=CountDays-1;shift++)
{
int length = ny_shift[shift+1]-ny_shift[shift];
high[shift] = High[iHighest(NULL,0,MODE_HIGH,length,ny_shift[shift])];
low[shift] = Low[iLowest(NULL,0,MODE_LOW,length,ny_shift[shift])];
range[shift] = high[shift] - low[shift];
}
for (shift=0;shift<=CountDays-1;shift++)
{
P = (ny_close[shift]+high[shift]+low[shift])/3;
Comment(range[0]/Point);
time1 = ny_time[shift]+Period()*60;
if (shift==0)
{
time2 = ny_time[shift] + 24*3600+Period()*60 ;
PlotVLine("pV0",time2,day);
PlotPrice("mPw",P,metka);
PlotPrice("mR1w",P+range[shift]/2,metka);
PlotPrice("mR2w",P+range[shift],metka);
PlotPrice("mS1w",P-range[shift]/2,metka);
PlotPrice("mS2w",P-range[shift],metka);
PlotPrice("mR3w",P+range[shift]+range[shift]/2,metka);
PlotPrice("mR4w",P+range[shift]*2,metka);
PlotPrice("mS3w",P-range[shift]-range[shift]/2,metka);
PlotPrice("mS4w",P-range[shift]*2,metka);
}
else
time2 = ny_time[shift-1]+Period()*60;
PlotVLine("pV["+shift+"]",time1,day);
int pstyle=0;
PlotLine("PPw["+shift+"]",P,P,pivot,pstyle);
PlotLine("R1w["+shift+"]",P+range[shift]/2, P+range[shift]/2,level_up,pstyle);
PlotLine("R2w["+shift+"]",P+range[shift], P+range[shift],level_up,pstyle);
PlotLine("R3w["+shift+"]",P+range[shift]+range[shift]/2, P+range[shift]+range[shift]/2,level_up,pstyle);
PlotLine("R4w["+shift+"]",P+range[shift]*2, P+range[shift]*2,level_up,pstyle);
PlotLine("S1w["+shift+"]",P-range[shift]/2, P-range[shift]/2,level_dn,pstyle);
PlotLine("S2w["+shift+"]",P-range[shift], P-range[shift],level_dn,pstyle);
PlotLine("S3w["+shift+"]",P-range[shift]-range[shift]/2, P-range[shift]-range[shift]/2,level_dn,pstyle);
PlotLine("S4w["+shift+"]",P-range[shift]*2, P-range[shift]*2,level_dn,pstyle);
PlotLine("GL1w["+shift+"]",P, P+range[shift]/2,setka,pstyle);
PlotLine("GL2w["+shift+"]",P+range[shift]/2, P+range[shift],setka,pstyle);
PlotLine("GL3w["+shift+"]",P+range[shift], P+range[shift]+range[shift]/2,setka,pstyle);
PlotLine("GL4w["+shift+"]",P+range[shift]+range[shift]/2,P+range[shift]*2,setka,pstyle);
PlotLine("GL5w["+shift+"]",P+range[shift]/2, P,setka,pstyle);
PlotLine("GL6w["+shift+"]",P+range[shift], P+range[shift]/2,setka,pstyle);
PlotLine("GL7w["+shift+"]",P+range[shift]+range[shift]/2,P+range[shift],setka,pstyle);
PlotLine("GL8w["+shift+"]",P+range[shift]*2, P+range[shift]+range[shift]/2,setka,pstyle);
PlotLine("GL9w["+shift+"]",P, P-range[shift]/2,setka,pstyle);
PlotLine("GL10w["+shift+"]",P-range[shift]/2, P-range[shift],setka,pstyle);
PlotLine("GL11w["+shift+"]",P-range[shift], P-range[shift]-range[shift]/2,setka,pstyle);
PlotLine("GL12w["+shift+"]",P-range[shift]-range[shift]/2,P-range[shift]*2,setka,pstyle);
PlotLine("GL13w["+shift+"]",P-range[shift]/2, P,setka,pstyle);
PlotLine("GL14w["+shift+"]",P-range[shift], P-range[shift]/2,setka,pstyle);
PlotLine("GL15w["+shift+"]",P-range[shift]-range[shift]/2,P-range[shift],setka,pstyle);
PlotLine("GL16w["+shift+"]",P-range[shift]*2, P-range[shift]-range[shift]/2,setka,pstyle);
}
fTime = false;
prevDay = cDay;
}
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
---