Before you start placing blocks and writing rules, it’s important to understand how a trading bot’s logic flows inside Profectus.
Think of your bot as a decision tree:
The bot starts at the top of a tree and works its way downwards
At each block, it makes a decision — either Yes or No — and then follows the connected path
You can build one or multiple trees that run at the same time, each with its own purpose (buying, selling, managing trades, etc.)
How Blocks Work
Each block is like a self-contained instruction:
It waits for a trigger (when to run)
It checks a condition (true or false)
It performs an action (place trade, modify stop loss, etc.)
Then it passes control to the next block connected to it
Outputs:
One output point: Always “Yes” — if the logic inside is true, the next block runs
Two output points: Left = “Yes” path, Right = “No” path
No inputs (top blocks): These are triggers — they start the flow
Best Practice for Structure
You don’t have to link everything together in a single chain.
The best approach is to split your bot into clear, separate trees:
Buy logic and execution
Sell logic and execution
Trade management (e.g., trailing stop loss, closing trades)
This keeps your project tidy and makes testing and debugging much easier.
The 4 Main Parts of Any Strategy
Every trading bot — no matter how simple or advanced — is built from these core components:
1. When to Trade (Triggers)
These blocks tell your bot when to run its checks:
Run per tick → executes on every market price change
Run per candle → executes once per completed candle
Example: “Check the strategy rules once every 1 hour candle.”
2. Trading Rules (Logic Checks)
These decide if a trade should be taken:
Trade Rule block → compare market data, indicators, or prices
Example: “If the last candle closed above the Moving Average”
The block gives a Yes or No result and moves to the next step accordingly.
3. Trade Execution
These blocks open positions:
Buy Now / Sell Now → instant orders
Pending Orders → place trades that will trigger later
You can set risk per trade as a percentage of your balance
4. Trade Management
These blocks manage open trades:
Select Trades → choose which trades to work with
Check Profit/Loss → see if a trade is in profit or loss
Modify SL/TP → adjust stop-loss or take-profit
Close Trades → exit trades based on your rules
Chart Object → add visual markers or notes on your chart
Example: Splitting Logic into Trees
Let’s say your strategy buys when the Moving Average points up and sells when it points down.
You could have:
Tree 1: Buy rules + Buy execution
Tree 2: Sell rules + Sell execution
Tree 3: Trade management for both sides
Each tree runs independently but at the same time.
Deploying to MetaTrader 5
Once your bot is ready:
Export it from Profectus as an MQL5 file
In MetaTrader 5: File → Open Data Folder
Paste into MQL5 > Experts and compile
Test it in the MT5 Strategy Tester or go live
👉 Full guide here: Exporting Your First Strategy
What’s Next?
This article is your high-level roadmap.
The next guides will go deep into each key area:
When to Trade → Triggers like Run per tick / Run per candle
Trading Rules → Mastering the Trade Rule block
Execution → Buy Now / Sell Now blocks
Management → Select Trades, Check Profit/Loss, Close Trades

