//+------------------------------------------------------------------+ //| PivotPoint.mq5 | //| Copyright 2018, Benjamin Pillet | //| | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, Benjamin Pillet" #property link "" #property version "1.00" #property indicator_chart_window #property indicator_buffers 7 #property indicator_plots 7 //--- plot pivot #property indicator_label1 "pivot" #property indicator_type1 DRAW_LINE #property indicator_color1 clrGold #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot R1 #property indicator_label2 "R1" #property indicator_type2 DRAW_LINE #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot R2 #property indicator_label3 "R2" #property indicator_type3 DRAW_LINE #property indicator_color3 clrRed #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- plot R3 #property indicator_label4 "R3" #property indicator_type4 DRAW_LINE #property indicator_color4 clrRed #property indicator_style4 STYLE_SOLID #property indicator_width4 1 //--- plot S1 #property indicator_label5 "S1" #property indicator_type5 DRAW_LINE #property indicator_color5 clrBlue #property indicator_style5 STYLE_SOLID #property indicator_width5 1 //--- plot S2 #property indicator_label6 "S2" #property indicator_type6 DRAW_LINE #property indicator_color6 clrBlue #property indicator_style6 STYLE_SOLID #property indicator_width6 1 //--- plot S3 #property indicator_label7 "S3" #property indicator_type7 DRAW_LINE #property indicator_color7 clrBlue #property indicator_style7 STYLE_SOLID #property indicator_width7 1 //--- indicator buffers double pivotBuffer[]; double R1Buffer[]; double R2Buffer[]; double R3Buffer[]; double S1Buffer[]; double S2Buffer[]; double S3Buffer[]; //--- input parameters and variables //input ENUM_TIMEFRAMES TFpivot = PERIOD_D1; input bool weekend; //merge Saturday and Sunday with Friday double P; double R1; double R2; double R3; double S1; double S2; double S3; int prevPeriod; double H=0; double L=0; double O=0; double newO=0; double C=0; MqlDateTime current; int pos; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,pivotBuffer,INDICATOR_DATA); SetIndexBuffer(1,R1Buffer,INDICATOR_DATA); SetIndexBuffer(2,R2Buffer,INDICATOR_DATA); SetIndexBuffer(3,R3Buffer,INDICATOR_DATA); SetIndexBuffer(4,S1Buffer,INDICATOR_DATA); SetIndexBuffer(5,S2Buffer,INDICATOR_DATA); SetIndexBuffer(6,S3Buffer,INDICATOR_DATA); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- pos = prev_calculated -1; if(pos < 1){ pos = 1; } for(int i=pos; iH){ H = high[i]; } if(low[i]