I do not know what the source of problem is but I found a solution:
//+------------------------------------------------------------------+ //| Create the "SpinEdit" element | //+------------------------------------------------------------------+ bool CControlsDialog::CreateSpinEdit(void) { //--- coordinates int x1=10; int y1=40; int x2=100; int y2=60; //--- create if(!m_spin_edit.Create(m_chart_id,m_name+"SpinEdit",m_subwin,x1,y1,x2,y2)) return(false); if(!Add(m_spin_edit)) return(false); m_spin_edit.MinValue(10); m_spin_edit.MaxValue(500); m_spin_edit.Value(spin_value+1); m_spin_edit.Value(spin_value); Print(spin_value); Comment(__FUNCTION__+" : Value="+IntegerToString(m_spin_edit.Value())); //--- succeed return(true); }
The issue is that the chart object is updated only if the value is different from the previous value. When you first load the EA the default value in spin edit is 0 and if you set another value it works as expetected, but when you destroy the control the value is not set back to 0, so if when you destroy the control the value is 70, then when you recreate the control and set 70 it won't update the ui because the value has not changed.
If you check bool CSpinEdit::CreateEdit(void) you can see that when the control is created it sets an empty string to the edit object instead of the value (default 0 in the first time or the value set before destroy).
//+------------------------------------------------------------------+ //| Create the edit field | //+------------------------------------------------------------------+ bool CSpinEdit::CreateEdit(void) { //--- create if(!m_edit.Create(m_chart_id,m_name+"Edit",m_subwin,0,0,Width(),Height())) return(false); if(!m_edit.Text("")) return(false); if(!m_edit.ReadOnly(true)) return(false); if(!Add(m_edit)) return(false); //--- succeed return(true); }
Since this method is virtual i suggest to create your own spin edit control derived from the CSpinEdit and override the method changing only the marked like to
if(!m_edit.Text((string)m_value))
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone. Here is a simple spin edit code.
It is working fine except that every time I change time frame the previous value is not shown. In order to keep the previous value I am using a global variable called: spin_value.
My experts log proves that the value is passed correctly after time frame change but for some unknown reason it is not shown except the first time EA loads.
Thanks for your help.