Building a bot
- Lesson 2 of 7
- Using Okkana
- steps
- 7
- terms explained
- 8
About this lesson
What you'll learn
How to build a bot: choose the market, set conditions with a metric, a timeframe and a threshold, combine them, pick a direction, avoid repeated signals, add exit levels and manage the bot afterwards.
Terms in this lesson
- Bot marketStep 1 · Choose the market
- Condition and thresholdStep 2 · Build a condition
- All or anyStep 3 · Combine conditions
- DirectionStep 4 · Set the direction
- CooldownStep 5 · Cooldown and reset
- ResetStep 5 · Cooldown and reset
- Take profit and stop lossStep 6 · Exit levels and delivery
- TemplatesStep 7 · Templates, status and cleanup
Choose the market
A bot watches one market, defined by an asset, a market type and a symbol: BTC, Perpetual, BTCUSDT. The same asset exists in several markets, and each one is separate, with its own price, volume and liquidity. A dated future is its own market too, and a bot can't use a contract that has already settled.
The market type decides which metrics a condition can read. Funding exists only on perpetuals, open interest and liquidations need a derivative, and basis needs a perpetual or a future. A condition that uses a metric the market doesn't have is rejected when you save.
A condition can also read another market, such as BTC's change on an ETH bot. That condition names its own market, and the Signal is still about the bot's market.
Build a condition
A condition has three parts: a metric with its timeframe, an operator and a threshold. Timeframes run from 1m to 1d. The operators are is above, is at or above, is below, is at or below, crosses above and crosses below.
The threshold can be a number, a multiple of the metric's own average over the last N candles, or another metric. The average lets one rule fit BTC and a small coin alike: volume at twice its average means something on both, while a fixed volume in dollars doesn't.
A bot holds up to 10 conditions. The values on each side of every condition at the moment the bot fires are saved with the Signal.
Combine conditions
With several conditions the bot needs a rule for combining them. With all, also called AND, every condition has to be true at the same moment. With any, also called OR, one is enough.
A bot uses one choice for all its conditions, because nested groups don't exist yet. Use all to narrow the search: a drop, heavy volume and a low RSI together. Use any to watch several different causes of the same alert.
Set the direction
The direction says which way the bot expects price to go, so the Signal's performance can be measured. Long measures a rise, Short measures a fall, and Alert only sends the Signal with the market move after it and no directional result. Okkana never infers the direction from the conditions: you choose it, or the template does.
Spot has no short. Shorting needs borrowing, a cost Okkana doesn't model, so a Spot bot is long, shown as Buy, or alert only. For a short, pick a perpetual or a future.
The direction is also the default when you confirm an entry on a Signal, and on an Alert only bot you choose it at that point.
Cooldown and reset
Two settings keep a bot from repeating itself. The cooldown is the minimum time between two Signals from the bot: 5 minutes up to 24 hours, or none. The reset is event-based: after firing, the conditions have to stop being true before the bot can fire again.
Say RSI stays below 30 for three hours. With the reset on, you get one Signal when it drops below 30, and the next only after it has gone back above 30 and below again. With the reset off, only the cooldown limits the bot, and it fires again each time the cooldown ends while the condition is still true. Every template has the reset on.
Exit levels and delivery
A bot can carry optional take profit and stop loss levels, as percent moves from the entry price with no leverage, such as +3% and -1.5%. Take profit takes above 0% and up to 1000%, stop loss above 0% and below 100%. They close the Signal's virtual position, so the bot's statistics reflect its own exit rule. Without levels the position closes at the 24h horizon. If one candle reaches both levels, the stop loss counts.
The levels live on the bot and never on an operation. A Signal keeps the levels the bot had when it fired, and editing them only affects later Signals. If you confirm an entry, the open operation alerts when price reaches a level measured from your entry.
When the conditions are met and the cooldown and reset allow it, the bot creates a Signal with the entry price and every condition's values, and sends an alert on each channel. In-app is always on. Webhook sends the Signal to your registered webhook and needs one in your profile.
Templates, status and cleanup
You don't have to start from a blank bot. Templates are starting points with the conditions, direction, cooldown and reset already filled in: oversold, overbought, breakout, volume spike, open interest expansion, potential squeezes, extreme funding and perpetual premium. Every threshold stays editable, and a template isn't a recommendation.
A bot is active, paused or a draft, and only an active bot watches the market. A paused bot keeps its history, and a draft doesn't watch until you activate it. Duplicate makes a copy as a draft. Delete stops the bot and removes its history, which can't be undone. Each account has a limit on the number of bots, and creating one past it fails.
Editing a bot affects later Signals only: each Signal keeps the rule that fired it.
These lessons explain what each number measures. They are not trading advice, and the lesson charts use simulated data. Preview build: market data on this site is simulated.