Compact Trade Panel
This page describes the fast-wrapper compact trade-style panel example.
It shows how to compose a small, realistic chart panel from existing ModernUI wrappers.
This example is UI-only. It does not place, modify, or close real orders.
File path
Experts/ModernUI/Examples/FastWrappers_CompactTradePanel_Demo.mq5
What this demonstrates
The example builds a compact panel with:
Mui::AppWindowfor the chart-hosted windowMui::Sectionfor grouped blocksMui::ButtonGroupfor Buy/Sell selectionMui::LabeledCombofor Market/Pending selectionMui::LabeledSpinEditfor lots and risk percentageMui::LabeledSliderfor an illustrative reward multipleMui::LabeledCheckboxfor a confirm-before-send settingMui::ButtonRowfor Place / Close / ResetMui::StatusRowfor status and connection-style badgesMui::SimpleTablefor a small local activity logMui::Toast,ToastSuccess, andToastWarningfor feedback
What this example does not do
The example does not include:
OrderSendCTradetrade.Buytrade.Sell- broker position close calls
- risk calculation against real account equity
- live order modification
- trading strategy logic
The controls are real UI controls. The trading behaviour is intentionally not included.
Why this example matters
Many MQL5 tools are not full dashboards. They are small chart panels that sit beside price action.
This example shows how to build that kind of panel without making ModernUI trading-specific.
The wrapper layer stays generic. The trade-style layout is just a composition example.
Shape of the UI
MuiAppWindow app=Mui::AppWindow(g_ui,"Trade Panel",28,28,360,500,true);
MuiSection order=Mui::Section(app.content,"Order","Sizing and intent - example values only.");
string sides[];
ArrayResize(sides,2);
sides[0]="Buy";
sides[1]="Sell";
MuiButtonGroup side=Mui::ButtonGroup(order.body,sides,0,0.0,0.0,true);
string kinds[];
ArrayResize(kinds,2);
kinds[0]="Market";
kinds[1]="Pending";
MuiLabeledCombo orderKind=Mui::LabeledCombo(order.body,"Type",kinds,0,0.0,0.0,"Execution style label for this demo.");
MuiLabeledSpinEdit lots=Mui::LabeledSpinEdit(order.body,"Lots",0.01,50.0,0.01,0.10,2);
MuiLabeledSpinEdit risk=Mui::LabeledSpinEdit(order.body,"Risk %",0.0,10.0,0.1,1.0,1);
MuiLabeledSlider reward=Mui::LabeledSlider(order.body,"Reward (x)",0.5,5.0,0.5,2.0);
Action row
For new EAs, assign IDs to the row buttons and handle clicks in OnMuiEvent(...).
MuiSection ctl=Mui::Section(app.content,"Controls","Actions are toasts and field resets - no trading API calls.");
string act[];
ArrayResize(act,3);
act[0]="Place";
act[1]="Close";
act[2]="Reset";
MuiButtonRow strip=Mui::ButtonRow(ctl.body,act,0.0,0.0,true);
if(strip.Count()>=1 && strip.Button(0)!=NULL)
strip.Button(0).Id(TP_ACTION_PLACE);
if(strip.Count()>=2 && strip.Button(1)!=NULL)
strip.Button(1).Id(TP_ACTION_CLOSE);
if(strip.Count()>=3 && strip.Button(2)!=NULL)
strip.Button(2).Id(TP_ACTION_RESET);
Route those IDs centrally:
if(event.EventId()==MUI_EVENT_CLICK && event.ControlId()==TP_ACTION_PLACE)
OnPlace(root);
Status rows
MuiStatusRow status=Mui::StatusRow(ctl.body,"Status","Ready","neutral");
MuiStatusRow connection=Mui::StatusRow(ctl.body,"Connection","Demo","info");
The example updates the status badge when the user presses Place.
if(g_status.badge!=NULL)
{
g_status.badge.Text("Stored");
g_status.badge.Variant(MUI_BADGE_SUCCESS);
}
Activity log
The activity log uses Mui::SimpleTable.
string hdr[];
ArrayResize(hdr,2);
hdr[0]="When";
hdr[1]="Detail";
MuiSimpleTable log=Mui::SimpleTable(logSec.body,hdr,3,328.0,118.0,true,true);
Rows are updated locally when the user taps Place.
What to click and test
After attaching the EA to a chart:
- Select Buy or Sell.
- Change Type between Market and Pending.
- Adjust Lots, Risk %, and Reward.
- Toggle Confirm before send.
- Click Place.
- Click Close.
- Click Reset.
- Watch the status badge, toast messages, and activity table.
All changes are local UI state only.
How to extend it safely
You can use this example as a starting point for your own tool, but keep UI and trading logic separate.
Recommended pattern:
UI reads values
→ validation layer checks values
→ trading service decides whether to call broker APIs
→ UI receives result and updates status
Do not put broker execution directly into random button handlers unless your EA is intentionally simple and you understand the consequences.
Common mistakes
Treating the demo as execution logic
The panel is a UI composition example. It is not a trade manager engine.
Making ModernUI trading-specific
Do not add trade-only helpers to the core API unless they are genuinely generic. Keep trade-specific composition inside examples or your own EA.
Forgetting handler ownership
For new EA code, prefer the event bus over one handler class per button.