Hello gentlemen ; programments,I thank you for your work, I want to ask you if you could put a button on this indicator , and if there is
the possibility of marking the lines shorter . Tank you
Code: Select all
#property indicator_chart_window
#property strict
extern string UniqueID = "YearlyPivots1"; // Unique ID
extern int LineWidth = 2; // Main lines width
extern int MidLineWidth = 0; // Midd lines width
extern ENUM_LINE_STYLE LineStyle = 0; // Main lines style
extern ENUM_LINE_STYLE MidLineStyle = 3; // Midd lines style
extern color P_color = clrLime; // Pivots color
extern color S_color = clrRed; // Support color
extern color MS_color = clrOrange; // Midd support color
extern color R_color = clrBlue; // Resistance color
extern color MR_color = clrAqua; // Midd resistance color
extern bool ShowMidPivots = true; // Show midd pivots?
extern bool ShowInBack = true; // Lines should be in background?
//------------------------------------------------------------------
//
//------------------------------------------------------------------
int init() { return(0); }
int deinit() { ObjectsDeleteAll(0,UniqueID+":"); return(0); }
int start()
{
MqlRates monthlyRates[];
MqlDateTime time; time.year = TimeYear(TimeCurrent())-1;
time.mon = 1;
time.day = 1;
time.hour = 0;
time.min = 0;
time.sec = 0;
datetime startTime = StructToTime(time); time.mon =12;
datetime endTime = StructToTime(time);
int months = CopyRates(NULL,PERIOD_MN1,startTime,endTime,monthlyRates);
if (months<1) return(0);
//
//
//
//
//
double high = monthlyRates[0].high;
double low = monthlyRates[0].low;
double close = monthlyRates[months-1].close;
for (int i=1; i<months; i++)
{
high = MathMax(monthlyRates[i].high,high);
low = MathMin(monthlyRates[i].low ,low);
}
double P=(high+low+close)/3;
double R1 = (2*P)-low;
double S1 = (2*P)-high;
double R2 = P + (R1-S1);
double S2 = P - (R1-S1);
double R3 = high+2*(P-low);
double S3 = low-2*(high-P);
double MR1=(P+R1)/2;
double MR2=(R1+R2)/2;
double MR3=(R2+R3)/2;
double MS1=(P+S1)/2;
double MS2=(S1+S2)/2;
double MS3=(S2+S3)/2;
CreateLine("Yearly_Pivot_P" ,"Pivot:",P ,P_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_R1","R1:" ,R1,R_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_R2","R2:" ,R2,R_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_R3","R3:" ,R3,R_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_S1","S1:" ,S1,S_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_S2","S2:" ,S2,S_color,LineStyle,LineWidth);
CreateLine("Yearly_Pivot_S3","S3:" ,S3,S_color,LineStyle,LineWidth);
if(ShowMidPivots==true)
{
CreateLine("Yearly_Pivot_MR1","MR1:",MR1,MR_color,MidLineStyle,MidLineWidth);
CreateLine("Yearly_Pivot_MR2","MR2:",MR2,MR_color,MidLineStyle,MidLineWidth);
CreateLine("Yearly_Pivot_MR3","MR3:",MR3,MR_color,MidLineStyle,MidLineWidth);
CreateLine("Yearly_Pivot_MS1","SR1:",MS1,MS_color,MidLineStyle,MidLineWidth);
CreateLine("Yearly_Pivot_MS2","SR2:",MS2,MS_color,MidLineStyle,MidLineWidth);
CreateLine("Yearly_Pivot_MS3","SR3:",MS3,MS_color,MidLineStyle,MidLineWidth);
}
return(0);
}
//
//
//
//
//
void CreateLine(string name, string text, double _price, color _color, int _style, int _width)
{
name = UniqueID+":"+name;
ObjectCreate(name, OBJ_HLINE, 0, 0, 0);
ObjectSet(name, OBJPROP_COLOR, _color);
ObjectSet(name, OBJPROP_PRICE1, _price);
ObjectSet(name, OBJPROP_STYLE, _style);
ObjectSet(name, OBJPROP_WIDTH, _width);
ObjectSet(name, OBJPROP_BACK, ShowInBack);
name = name+":l";
ObjectCreate(name, OBJ_TEXT, 0, 0, 0);
ObjectSet(name, OBJPROP_COLOR, _color);
ObjectSet(name, OBJPROP_TIME1, Time[0]);
ObjectSet(name, OBJPROP_PRICE1, _price);
ObjectSet(name, OBJPROP_BACK, ShowInBack);
ObjectSetText(name,text+DoubleToStr(_price,Digits));
}