Spin Edit
Use SpinEdit for numeric values.
It is a better fit than a text box when the value has a known range, step size, or number of decimals.
Main helpers
| Helper | Use it for |
|---|---|
Mui::SpinEdit |
Raw numeric control |
Mui::LabeledSpinEdit |
Label plus numeric control |
Basic SpinEdit
MuiSpinEditHost *risk=Mui::SpinEdit(
parent,
0.1,
10.0,
1.0,
0.1,
1,
NULL,
220.0,
0.0
);
Argument order:
parent, min, max, initial, step, decimals, handler, width, height
LabeledSpinEdit
For form panels, prefer the labelled wrapper.
MuiLabeledSpinEdit risk=Mui::LabeledSpinEdit(
section.body,
"Risk %",
0.1,
10.0,
0.1,
1.0,
1,
0.0,
0.0,
"Percent value only. Your EA decides how to use it."
);
The labelled wrapper order is:
parent, label, min, max, step, value, digits, width, height, hint
Reading and setting values
if(risk.control!=NULL)
{
double current=risk.control.Value();
risk.control.Value(2.0);
}
Stepper style
MuiSpinEditHost uses one shared input border. The increment/decrement buttons sit flush inside the right side of the input, so the control reads as one field rather than a field with a separate mini box attached.
The default stepper style uses a subtle filled background for the up/down halves. The fill is derived from the input border colour, while the chevrons use text colours so they stay readable.
You can choose the flatter style if you want less visible stepper buttons:
if(risk.control!=NULL)
risk.control.StepperFilled(false);
Use the default filled style for most panels. It gives the stepper clearer affordance without adding another outline.
Common uses
Spin edits are useful for:
- risk percentage
- lot size
- stop-loss points
- take-profit points
- maximum trades
- slippage setting
- timer interval
- threshold values
- numeric dashboard settings
Event bus pattern
For normal EA code, assign an ID and handle MUI_EVENT_VALUE_CHANGED in OnMuiEvent(...).
MuiSpinEditHost *risk=Mui::SpinEdit(parent,0.1,10.0,1.0,0.1,1,NULL,220.0,0.0);
risk.Id(PANEL_ACTION_RISK_CHANGED);
if(event.EventId()==MUI_EVENT_VALUE_CHANGED && event.ControlId()==PANEL_ACTION_RISK_CHANGED)
Print("Risk changed: ",DoubleToString(event.Value(),1));
Low-level spin handlers still exist for advanced reusable controls, but normal EA panels should prefer the event bus.
Spin edit vs slider
| Need | Use |
|---|---|
| Exact numeric value | SpinEdit |
| Fast approximate adjustment | Slider |
| Both exact and visual adjustment | Use both and keep them synced in your EA |
Spin edit vs text box
Use SpinEdit when the value must be numeric.
Use TextBox when the value is free text.
Common mistakes
Wrong argument order
Raw Mui::SpinEdit and Mui::LabeledSpinEdit have different argument order because the labelled wrapper includes the label first.
Treating UI value as validated business logic
Spin edit clamps and formats UI values. Your EA should still validate before applying important settings.
Using too many decimals
Keep digits practical. For example, risk percentage often only needs one or two decimals.
Hiding the stepper affordance unintentionally
StepperFilled(false) is useful for a very flat style, but the default filled stepper is usually clearer for users because it shows that the up/down halves are clickable.
Related pages
- MuiSpinEditHost — events, setters, native host notes
Mui::LabeledSpinEdit— risk-style labeled row helper- Event Bus —
MUI_EVENT_VALUE_CHANGED - Labeled inputs
- Checkbox, toggle, and slider
- Text inputs