//+------------------------------------------------------------------+
//| TD_DRP.mq4 |
//| Oleg-Vaócheslav |
//| http://www.ru |
//+------------------------------------------------------------------+
#property copyright "Oleg-Vaócheslav"
#property link "http://www.ru"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Maroon
#property indicator_color3 Green
double X, Max, Min, Top, Down;
double maxline[],midline[],minline[],hline[];
string obj_name;
int code=250;
double n=1.0001;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
SetIndexBuffer(0, maxline);
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(1, midline);
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(2, minline);
SetIndexStyle (2, DRAW_LINE, STYLE_SOLID, 1);
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
for (int i = Bars; i>=0; i--)
{
if (Close[i+1]<Open[i+1])
{
X =((High[i+1]+Low[i+1]+Close[i+1]+Low[i+1])/2);
Max = (X - Low[i+1]);
Min = (X - High[i+1]);
Top = (Max-Open[i]);
Down= (Open[i]- Min);
}
if (Close[i+1]>Open[i+1])
{
X =((High[i+1]+Low[i+1]+Close[i+1]+High[i+1])/2);
Max = (X - Low[i+1]);
Min = (X - High[i+1]);
Top = (Max-Open[i]);
Down= (Open[i]- Min);
}
if (Close[i+1]==Open[i+1])
{
X =((High[i+1]+Low[i+1]+Close[i+1]+Close[i+1])/2);
Max = (X - Low[i+1]);
Min = (X - High[i+1]);
Top = (Max-Open[i]);
Down= (Open[i]- Min);
}
// ÏÐÎÐÈÑÎÂÊÀ
maxline[i] = Max;
midline[i] = Open[i];
minline[i] = Min;
}
Comment("Top: ",Top,"\nDown: ",Down);
obj_name="maxline";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Max, Time[0], Max);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Max, Time[0], Max);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_DASH);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
}
obj_name="midline";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Open[0], Time[0], Open[0]);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Open[0], Time[0], Open[0]);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_DASH);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
}
obj_name="minline";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Min, Time[0], Min);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TREND, 0, Time[1], Min, Time[0], Min);
ObjectSet(obj_name, OBJPROP_STYLE, STYLE_DASH);
ObjectSet(obj_name, OBJPROP_COLOR, DodgerBlue);
}
obj_name="midtext";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Open[0]);
ObjectSet(obj_name, OBJPROP_COLOR, Maroon);
ObjectSetText(obj_name,"open",5);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Open[0]);
ObjectSet(obj_name, OBJPROP_COLOR, Maroon);
ObjectSetText(obj_name,"Open[0]",8);
}
obj_name="maxtext";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Max);
ObjectSet(obj_name, OBJPROP_COLOR, Red);
ObjectSetText(obj_name,"open",5);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Max);
ObjectSet(obj_name, OBJPROP_COLOR, Red);
ObjectSetText(obj_name,"Max",8);
}
obj_name="mintext";
if (ObjectFind(obj_name)==-1)
{
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Min);
ObjectSet(obj_name, OBJPROP_COLOR, Green);
ObjectSetText(obj_name,"open",5);
} else {
ObjectDelete(obj_name);
ObjectCreate(obj_name, OBJ_TEXT, 0, Time[0], Min);
ObjectSet(obj_name, OBJPROP_COLOR, Green);
ObjectSetText(obj_name,"Min",8);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments