-
Notifications
You must be signed in to change notification settings - Fork 5
Description
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
backtestd-expert/Include/backtestd/SignalClass/CustomSignal.mqh
Lines 174 to 186 in 3860f55
| 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()
backtestd-expert/Include/backtestd/SignalClass/CustomSignal.mqh
Lines 235 to 253 in 3860f55
| 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 ;)