Feature
Botscript
Botscript is the text form of a bot. Blocks and botscript are two views of the same program: edit one and the other updates, as long as the script compiles.
The shape of a script
The first line names the bot. Guard lines set the risk guards. Each rule starts with when, lists conditions joined by one kind of joiner (and, or or xor), and ends with then and an action. The action may sit on the same line as the conditions.
Lines starting with # are comments. Blank lines are ignored.
bot "Oversold Sniper"
guard max_per_trade $2000
guard max_invested 80%
when rsi(14) < 30 and cooldown 24
then buy 100%
when pnl down 8% on wick
then sell 100%
Statements
bot "Name": names the bot.guard max_per_trade $2000(oroff): caps every single buy.guard max_invested 80%: the most of your equity that may be in BTC.guard stacking on: allow buying more while already holding.fee 0.1%andslippage 0.05%: the bot's trading costs on every fill.when …/then …: one rule.not <condition>: inverts one condition.
Conditions
- Price:
price down 3% in 24,price crosses above $100000,breakout high 48,candle green 2%,streak red 3. - Indicators:
price crosses above sma(50),price crosses below ema(21),sma(20) crosses above sma(100),rsi(14) < 30,macd(12,26,9) crosses above signal,price below bb_lower(20,2),stoch(14,3) < 20,atr(14) > 1.5%,volatility(24) > 1.5%,supertrend(10,3) flips bullish,adx(14) > 25,dmi(14) crosses bullish,price below kc_lower(20,10,1.5),cci(20) < -100,willr(14) < -80,price below chandelier(22,3). - Patterns:
pattern hammer,fvg bullish 0.5%,sweep low 48. - Timing:
hour 8..16,day monday,cooldown 12,buys per day < 2,buys per week < 5. - Portfolio:
holding,flat,pnl up 5%,pnl down $300,pnl down 8% on wick,trailing 5%,trailing 5% on wick,held >= 48,held < 12,equity > $12000,drawdown 15%. - Higher timeframe: end any price, indicator or pattern condition with
onand a timeframe, as inrsi(14) < 30 on 4horprice crosses above sma(50) on 1d.
Actions
buy 50%: invest a share of available cash.buy $1000: invest a fixed dollar amount.sell 100%: sell a share of the position.sell $500: sell a fixed dollar amount.buy 100% limit 1%,buy 50% stop 2%,sell 100% limit 3% expires 24: a limit or stop order X% from the close, working for 12 candles unlessexpiressays otherwise.
Errors
The compiler never guesses. A line it cannot read is reported with its line number and a hint, and the script is not applied until it is clean, so a typo cannot silently change your bot.
Botscript: frequently asked questions
Is botscript a programming language?
It is a small rule language, not a general one: no variables or loops, just conditions, actions and guards. That keeps every bot readable and safe to run.
Can I mix and and or in one rule?
No. Each rule uses one joiner. Split the logic into two rules if you need both.
Are blocks and botscript the same bot?
Yes. The Lab compiles script into blocks and prints blocks back as script, losslessly.
Is it case-sensitive?
Keywords are not. Bot names and imported indicator names keep their case.
Can I use my TradingView indicators in botscript?
You can reference imported Pine Script indicators with pine("Name").output. They run in simulations on the Pro and Quant plans.
Related
Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.