Tâche terminée
Spécifications
1. Objective: Objective: Write a technical indicator in MQL5 programming language to be used in Expert Advisorr
2. Indicator name: HiLo Box MTF Indicator
3. Source Code:
· .mq5 file must be supplied with the source code (.mq5)
· . mq5 file must be written in English
· mq5 file should be all commented as the files are distributed along with the MT5 terminal, example in red:
//+------------------------------------------------------------------+
//|
Custom
indicator initialization function
|
//+------------------------------------------------------------------+
void OnInit()
{
//---
check for input value
if(InpWPRPeriod<3)
{
ExtPeriodWPR=14;
Print("Incorrect
InpWPRPeriod value. Indicator will use value=",ExtPeriodWPR);
}
else ExtPeriodWPR=InpWPRPeriod;
//----
name for DataWindow and
indicator subwindow label
IndicatorSetString(INDICATOR_SHORTNAME,"%R"+"("+string(ExtPeriodWPR)+")");
//----
indicator's buffer
SetIndexBuffer(0,ExtWPRBuffer);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtPeriodWPR-1);
//--- digits
IndicatorSetInteger(INDICATOR_DIGITS,2);
//----
}
//+------------------------------------------------------------------+
//| Williams’ Percent
Range |
//+------------------------------------------------------------------+
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[])
{
//---- insufficient
data
if(rates_total<ExtPeriodWPR)
return(0);
//--- start working
int i=prev_calculated-1;
//--- correct position
if(i<ExtPeriodWPR-1) i=ExtPeriodWPR-1;
//--- main
cycle
while(i<rates_total && !IsStopped())
{
//--- calculate maximum High
double dMaxHigh=MaxAr(high,ExtPeriodWPR,i);
//---
calculate minimum Low
double dMinLow=MinAr(low,ExtPeriodWPR,i);
//--- calculate WPR
if(dMaxHigh!=dMinLow)
ExtWPRBuffer[i]=-(dMaxHigh-close[i])*100/(dMaxHigh-dMinLow);
else
ExtWPRBuffer[i]=ExtWPRBuffer[i-1];
//--- increment i for next iteration
i++;
}
//--- return new prev_calculated value
return(rates_total);
}
4. Description Functioning: The indicator should plotting on the graph the design of a box based on the maximum(high) and minimum (low) prices in accordance with a specific amount of candles and timeframe set by the Trader in the parameters, every time that close one or more candlestick will be deleted the previous box and plotted a new box. The amount of closed candles to be plotted HiLo Box MTF is specified by the Trader in External parameters
5. Mode Functioning: FULL and INTERMITTENT
FULL:
INTERMITTENT