The entire chain: Candels High Open indicator, Expert Advisor based on the CandelsHighOpen signal module.
The SignalCandelsHighOpen module of trading signals assumes that the Candels High Open custom indicator has already been compiled and placed to \MQL5\Indicators\. This path is specified in the module of the next code block:
//| Create the “Candels High Open” indicator |
//+——————————————————————+
bool CSignalCHO::CreateCandelsHighOpen(CIndicators *indicators)
{
//— pointer check
if(indicators==NULL) return(false);
//— add the object to the collection
if(!indicators.Add(GetPointer(m_SignalCHO)))
{
printf(__FUNCTION__+“: failed to add CandelsHighOpen object”);
return(false);
}
//— set Candels High Open indicator parameters
MqlParam parameters[2];
//—
parameters[0].type=TYPE_STRING;
parameters[0].string_value=“Candels High Open.ex5”;
parameters[1].type=TYPE_INT;
parameters[1].integer_value=m_reverse_signals; // reverse
//— object initialization
if(!m_SignalCHO.Create(m_symbol.Name(),m_period,IND_CUSTOM,2,parameters))
{
printf(__FUNCTION__+“: failed to initialize CandelsHighOpen object”);
return(false);
}
//— number of buffers
if(!m_SignalCHO.NumBuffers(1)) return(false);
//— reaching this string means the function is executed successfully – return ‘true’
return(true);
}
If the indicator is placed to another folder, like \MQL5\Indicators\Examples\, the path to the indicator is as follows:
Buy and sell signals:
Since the Candels High Open indicator contains only three values in its buffer:
- “+1” – buy signal
- “0” – no signal
- and “-1” – sell signal
//| Return the buy signal power |
//+——————————————————————+
int CSignalCHO::LongCondition()
{
int signal=0;
//— for working by ticks idx=0, for working by complete bars idx=1
int idx=StartIndex();
//— signal values on the last complete bar
double ind_value=Signal(idx);
//—
if(ind_value>0.0)
{
signal=100; // a buy signal is present
}
//— return the signal value
return(signal);
}
//+——————————————————————+
//| Return a sell signal power |
//+——————————————————————+
int CSignalCHO::ShortCondition()
{
int signal=0;
//— for working by ticks idx=0, for working by complete bars idx=1
int idx=StartIndex();
//— signal values on the last complete bar
double ind_value=Signal(idx);
//—
if(ind_value<0.0)
{
signal=100; // a sell signal is present
}
//— return the signal value
return(signal);
}
When generating an EA via the MQL5 Wizard, search for the signal module with the “Analyzing High and Open of the last three bars” description: