Skip to content
ModernUI A DaneTrades developer library

Showcase trade panel

TradePanel_Showcase.mq5 is the polished compact trade-style showcase.

Use it when you want to see a more product-quality panel with drawer settings, confirmation behaviour, status bar, badges, risk-style inputs, theme accents, and central event-bus routing.

This example is UI-only. It does not place, modify, or close real orders.

File path

Reference excerpt
Experts/ModernUI/Examples/Demos/TradePanel_Showcase.mq5

What this demonstrates

The showcase panel includes:

  • one main panel class inheriting MuiEventSink
  • controls created normally and assigned .Id(...)
  • one central OnMuiEvent(...) method
  • compact chart-hosted window
  • chart symbol badge
  • settings drawer
  • risk percentage input
  • lot input
  • SL/TP spin edits
  • R:R slider
  • risk/reward summary labels
  • Buy / Sell buttons
  • optional warning row
  • bottom status bar
  • theme accent presets in the drawer
  • simulated confirmation and toast feedback

What this example does not do

The file comments are explicit: the demo is simulated UI and math only.

It does not call OrderSend, CTrade, trade.Buy, trade.Sell, PositionClose, or broker position APIs.

Buy and Sell either open a demo confirmation dialog or call a simulated local function that logs and shows a toast.

How to run it

  1. Open Experts/ModernUI/Examples/Demos/TradePanel_Showcase.mq5.
  2. Compile it in MetaEditor.
  3. Attach it to a chart.
  4. Interact with the panel controls and settings drawer.

Event-bus structure

The showcase follows the recommended ModernUI EA structure:

Pseudo-code
class CTradePanelShowcase : public MuiEventSink
-> m_ui.SetEventSink(...)
-> CreateGUI / CreateHeader / CreateRiskInputs / ...
-> controls assign .Id(...)
-> OnMuiEvent routes actions
-> user action methods perform behaviour

Example control creation:

UI build fragment
m_bBuy=Mui::Button(cExecution,"BUY");
m_bBuy.Id(TP_ACTION_BUY);

m_sRiskReward=Mui::HorizontalSlider(cSlider,1.0,5.0,2.0,NULL,0.0,10.0,0.5,false);
m_sRiskReward.Id(TP_ACTION_RR_CHANGED);

Example routing:

Reference excerpt
if(event.EventId()==MUI_EVENT_CLICK && event.ControlId()==TP_ACTION_BUY)
   OnBuy(root);

if(event.EventId()==MUI_EVENT_VALUE_CHANGED && event.ControlId()==TP_ACTION_RR_CHANGED)
   OnRiskRewardChanged(root,event.Value());

Adapting this example

When adapting this panel:

  1. Keep UI construction separate from trading execution.
  2. Keep validation separate from user action methods where possible.
  3. Make broker-facing actions explicit.
  4. Keep warnings and confirmations visible.
  5. Avoid promising trading performance.

A safe structure is:

Pseudo-code
UI event
-> validation
-> execution service
-> result object
-> UI feedback

Controls and API reference

Control in source API reference Events used in showcase
Mui::AppWindow Factory helpers
Mui::LabeledSpinEdit (risk, lot, SL, TP) LabeledSpinEdit · Spin edit MUI_EVENT_VALUE_CHANGED (TP_ACTION_INPUT_CHANGED)
Mui::HorizontalSlider Slider MUI_EVENT_VALUE_CHANGED (TP_ACTION_RR_CHANGED)
Mui::Button, ButtonDanger, IconButton Buttons MUI_EVENT_CLICK
Mui::Checkbox Checkbox MUI_EVENT_CHECK_CHANGED
Mui::Drawer Drawer MUI_EVENT_DRAWER_STATE
MuiDialog + confirm Dialog MUI_EVENT_DIALOG_RESULT, MUI_EVENT_CONFIRM
Mui::Badge, Mui::Label, MuiStatusBar Display none
Mui::ToastSuccess Toast helpers none

Read payloads in Event Bus. Source matches the recommended pattern: handler is NULL, .Id(...) on interactive controls, routing in OnMuiEvent.

Related pages