Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicators can only have int or double inputs #2

Open
stfl opened this issue Sep 23, 2020 · 0 comments
Open

Indicators can only have int or double inputs #2

stfl opened this issue Sep 23, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@stfl
Copy link
Owner

stfl commented Sep 23, 2020

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 ;)

@stfl stfl added the enhancement New feature or request label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant