Hi,
Newbie here.
I want to make simple indicator but error. I’m stuck. Actually this is my first indi to make.
Formula :
Indicator Signal = ((Highest Hi previous 10 period - Lowest Low previous 10 period) / 3) + Lowest Low previous 10 period
Anyone can help me?
//+------------------------------------------------------------------+
//| 310-indi.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//--- plot Signal
#property indicator_label1 "Signal"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- indicator buffers
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,SignalBuffer,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[])
{
//---
double HH[], LL[], Range [];
ArraySetAsSeries(HH,true);
ArraySetAsSeries(LL,true);
ArraySetAsSeries(Range,true);
int i;
for(i=prev_calculated;i<rates_total;i++)
{
HH[i] = ArrayMaximum (high,0,11);
LL[i] = ArrayMinimum (low,0,11);
Range[i] = round((HH[i]-LL[i])/3);
double newLL = LL[i]+Range[i];
SignalBuffer[i] = newLL;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+