Skip to content

main_sugar.py

What this file is

Demonstration script showcasing high-level sugar methods that wrap low-level MT4 RPC calls. It’s meant for quick onboarding: readable calls, sane defaults, and concise examples.

Tips for working with this demo

  • Set defaults first. Call set_defaults(...) for symbol/magic/pip settings to reduce noise.
  • Ensure connectivity. Use await ensure_connected() and occasional await ping() in loops.
  • Normalize before send. Normalize price and lots; convert pips↔price with helpers.
  • Use context overrides. with_defaults(...) for temporary symbol/magic in a scoped block.
  • Log outcomes. Print compact results (ticket, price, sl/tp) rather than raw objects.

Output

You should see readable prints for each sugar call (quotes, placements, modifications, etc.).

Sugar Output