Hi.
I tried to make a pivot point indicator, but i don’t know whats wrong, because its not displaying any lines but for the high[i] it showing lines…
i dont know why i find it difficult learning how to do this but am a good programmer when it comes to Expert Advisors
//+------------------------------------------------------------------+
//| Iyke's Pivot Point.mq4 |
//| Copyright 2017, Wik |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Wik"
#property version "1.00"
#property strict
#property indicator_chart_window
//----
#property indicator_buffers 7
#property indicator_color1 clrWhite
#property indicator_color2 clrGreen
#property indicator_color3 clrGreen
#property indicator_color4 clrGreen
#property indicator_color5 clrRed
#property indicator_color6 clrRed
#property indicator_color7 clrRed
//---
double PP[],S1[],S2[],S3[],R1[],R2[],R3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorShortName("Iyke's Pivot Point");
//---
datetime StartingTime=iTime(NULL,PERIOD_MN1,0);
//---
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PP);
SetIndexLabel(0,"PP");
//---
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,S1);
//SetIndexDrawBegin(1,StartingTime);
SetIndexLabel(1,"S1");
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[])
{
//---
for(int i=prev_calculated; i<rates_total; i++)
{
//-----WEEKLY PIVOTS TIME FRAME
double WeeklyHigh=NormalizeDouble(iHigh(NULL,PERIOD_W1,1),5);
double WeeklyLow=NormalizeDouble(iLow(NULL,PERIOD_W1,1),5);
double WeeklyClose=NormalizeDouble(iClose(NULL,PERIOD_W1,1),5);
//-----WEEKLY PIVOT CALCULATION
double PivotPoint=NormalizeDouble((WeeklyHigh+WeeklyLow+WeeklyClose)/3,5);
double Res1=NormalizeDouble((2*PivotPoint)-WeeklyLow,5);
double Sup1=NormalizeDouble((2*PivotPoint)-WeeklyHigh,5);
double Res2=NormalizeDouble(PivotPoint+(WeeklyHigh-WeeklyLow),5);
double Sup2=NormalizeDouble(PivotPoint-(WeeklyHigh-WeeklyLow),5);
double Res3=NormalizeDouble(WeeklyHigh+2*(PivotPoint-WeeklyLow),5);
double Sup3= NormalizeDouble(WeeklyLow-2*(WeeklyHigh-PivotPoint),5);
//---
PP[i]=PivotPoint;
S1[i]=high[i];
}
return(0);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+