Skip to content

Indicators can only have int or double inputs #2

@stfl

Description

@stfl

Problem

The EA input fields are of type double. Transparently using them for int is no problem.
string or bool does not work

If an Indicator has string or bool values mixed in with other inputs the iCustom initialization method fails and the Indicator cannot be instantiated.

inputs[] is simply copied to m_params

void CCustomSignal::ParamsFromInput(double &inputs[]) {
uint size = ArraySize(inputs);
m_params_size = size+1;
ArrayResize(m_params, m_params_size);
m_params[0].type=TYPE_STRING;
m_params[0].string_value=m_indicator_file;
for(uint i=0; i<size; i++) {
m_params[i+1].type=TYPE_DOUBLE;
m_params[i+1].double_value=inputs[i];
}
}

and m_params is then used for m_indicator.Create()

bool CCustomSignal::InitCustomIndicator(CIndicators *indicators)
{
//--- check pointer
if(indicators==NULL)
return(false);
//--- add object to collection
if(!indicators.Add(GetPointer(m_indicator)))
{
printf(__FUNCTION__+": error adding object");
return(false);
}
if(!m_indicator.Create(m_symbol.Name(), m_period, m_indicator_type, m_params_size, m_params))
{
printf(__FUNCTION__+": error initializing object");
return(false);
}
//--- ok
return(true);
}

Workaround

Simply comment out string and bool inputs in the Indicator source and compile again ;)
string or bool inputs have no meaning for backtesting anyway..
bool can also be converted to float and typecasted to bool ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions