Of course I'm willing to provide more details on it and only expect help.
The initial question was just that, a question to see if there was anybody here who could do so.
This is the coding:
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrBlue
#property indicator_color2 clrBlue
#property indicator_width1 10
#property indicator_width2 10
double BodyHigh[];
double BodyLow[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,BodyHigh);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(1,BodyLow);
SetIndexStyle(1,DRAW_HISTOGRAM);
//---
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=Bars-2-IndicatorCounted();i>=0;i--)
{
Print (i);
double hi=high[i];
double lo=low[i];
double prevhi=high[i+1];
double prevlo=low[i+1];
double bodyhigh=MathMax (close[i],open[i]);
double bodylow=MathMin (close[i],open[i]);
if(hi>prevhi&&lo<prevlo)
{
BodyHigh[i]=bodyhigh;
BodyLow[i]=bodylow;
}
}
return(rates_total);
}
//+------------------------------------------------------------------+
For some reason there are many candles which do look like they would be engulfing, but aren't being indicated as such.
Thanks.
- www.mql5.com
Maybe this helps you to find a solution?
I tell you there is practically nothing that does not exist for MT4/5. So searching for a couple on minutes saves you hours of coding in many times!
- 2015.09.22
- Dmitry Iglakov
- www.mql5.com
Please use the SRC button when posting code. I have done it for you this time.
if Bars=1000 and IndicatorCounted=999, your calculation for i will return
i=1000-2-999
which is minus 1 which is not a valid bar index.
You print I, but as the loop is not executed, there is no print, so haven't you noticed this?
- Don't "declare all variables as globals" That is bad programming.
- Arrays are ~10x slower than variables. Cache them in variables where possible.
for(;;){ T next = arr[--iNext]; if(!(value < next)) break; arr[iEmpty] = next; iEmpty = iNext; }
- Don't do per tick what you can do once per bar. If you're waiting for price to reach a trigger, ignore all ticks until you reach it (or a new bar starts and you recalculate.)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can anyone help with an engulfing indicator? I have one but it isn't indicating on all the candles for some reason.
Thanks.