Python mode
Python mode is the fastest way to see whether an idea is worth anything. You describe a strategy, the assistant writes Python against a pre-loaded price DataFrame, and the Chart tab redraws in seconds — no install, no compiler, no queue. When the idea holds up, you export it to Pine Script, MQL5 or NinjaScript and trade it there.
What it is — and what it isn't
Your script runs in a sandbox that has already done the boring part. A DataFrame called data is waiting for you with open, high, low, close, volume and a datetime index, pandas and numpy are imported, and pandas_ta is registered so data.ta.ema(length=20) and ta.rsi(data['close']) just work.
What it isn't is arbitrary Python. You draw by calling a fixed set of house helpers — add_line_series, add_fill, add_markers_where and friends — and you declare trades with set_long_entry / set_short_entry. There is no plt.show(), no file to save, no network call. That narrow API is the point: it's what makes the chart instant and what makes an export to another language possible.
1) Pick Python on the New Script page
- Go to app.horizontrading.ai and open the New Script page.
- In the language toggle at the top, choose Python (it sits alongside Pine Script, MQL5 and NinjaScript).
- Describe what you want, e.g. "Plot a 20/50 EMA crossover on EUR/USD and mark the crossovers."
2) Watch the Chart tab, not the code
In the right-hand panel, switch to Chart. This is the hero of Python mode: candles for the symbol you picked, with your indicators drawn over them.
You don't press Run. The chart re-executes on its own whenever the assistant applies an edit, so it repaints mid-reply — you often see the new moving average appear before the assistant has finished explaining it. A typical redraw takes a couple of seconds.
Pick the symbol and timeframe from the toolbar above the chart. The symbol box is searchable: it opens on a curated list (major FX pairs, gold and silver, the big crypto pairs, a handful of US megacaps) but typing searches a much wider universe of instruments. Timeframes are 1m, 5m, 15m, 30m, 1h, 4h and 1D.
3) Ask for the visuals you want
You don't need to know the helper names — ask in plain language and the assistant picks them. It's worth knowing what's available, though, because the chart can do more than most people ask it for:
- Lines — moving averages, oscillator lines, any series you can compute.
- Histograms — MACD histograms, volume bars, anything two-sided that colours by sign.
- Fills between two series — Bollinger and Keltner bands, the Ichimoku cloud, Supertrend. Either bound can be a plain number, so fixed thresholds work too.
- Areas — a line with a gradient fading away underneath it.
- Price lines — one horizontal level, tagged on the price axis.
- Zones — a shaded band across the full width of the chart (overbought/oversold).
- Boxes — a rectangle bounded in time as well as price.
- Trendline segments — a line from one bar and price to another.
- Markers — arrows or dots on the bars where a condition is true, above or below the candle, with text.
- Bar colours — colour the candles themselves from a condition, a signed series, or explicit colours.
- Labels — free-floating text anchored to a bar and a price.
- Tables — a pinned stats panel over the chart (top-left, top-right, bottom-left or bottom-right).
Ask for things like "shade the Bollinger band instead of drawing two lines" or "put a summary table in the top right with the current RSI and trend."
4) Use named lower panes
Panes are names. Anything drawn to main sits on the price chart; any other name gets its own pane underneath, and two overlays naming the same pane share it. So an RSI and a MACD land in two separate lower panes rather than fighting over one.
Say "put the RSI in its own pane with the 70 and 30 levels shaded" and you'll get a lower pane with the line, the zones and the levels together. The legend above the chart lists every series — click an entry to hide or show it without touching the code.
5) Let it fix its own mistakes
There's no compiler here, so "does it compile?" means "does it run?". After every write or edit, the assistant executes the script in the sandbox against real candles. If it raises, it sees the error — with the line number mapped back onto your code, not the sandbox harness — and fixes it before handing the turn back.
The same thing happens when a run fails in front of you: the error is fed back into the conversation and the assistant has another go. So a KeyError on an indicator column or a stray unsupported colour usually resolves itself without you doing anything.
6) Take it somewhere you can trade it
Python mode has no live execution and never will — it's the workshop. Once the chart and the numbers look right, use Export in the chat header to get the same strategy as Pine Script, MQL5 or NinjaScript. See Export Python to Pine, MQL5 or NinjaScript.
Limits, defaults & fine print
- Available on every plan — the Chart tab is not gated. (Running a backtest is Pro/Elite; see Backtesting Python Strategies.)
- Libraries:
pandas,numpyandpandas_taonly, all pre-imported. Nothing else is installed and nothing can be fetched. - No network, no filesystem, no processes. The sandbox rejects code touching
os.,sys.,subprocess,open(,eval(,exec(,socket,urlliborrequestsbefore it runs. - Execution timeout: 10 seconds per chart run.
- Vectorized pandas only — no
forloops over bars. That's a real constraint of the mode, not a style preference. volumealways exists as a column but is empty for forex and most CFDs — those instruments genuinely report none, so volume-based indicators come out blank on EUR/USD and similar. Test them on a stock or a crypto pair.- One instrument, one timeframe per run. There's no multi-timeframe request — the sandbox only ever sees the candles for the symbol and timeframe in the toolbar.
- Colours must be hex (
"#22C55E") or a colour name the chart library actually carries."lightgray"is the classic trap — it isn't one of them. - History: roughly the last 730 bars on intraday timeframes and 1,825 bars on 1D. Long lookbacks (a 200-period EMA on 1m) will have a blank warm-up at the left edge.
Troubleshooting
- "Code executed successfully but no visualizations were generated" — the script calculated an indicator but never drew it. Ask the assistant to "plot it on the chart"; every calculation needs a matching
add_*call. - "Security violation: blocked pattern" — the code reached for something the sandbox forbids (file access, imports, network). Ask for a version that works only from
data. - "Execution timeout (max 10 seconds)" — almost always a loop over bars. Ask the assistant to "rewrite this using vectorized pandas."
- "Cannot parse color" — an unsupported colour name. Ask for hex values instead; the error names the offending value.
- Volume indicators draw nothing — you're on a forex pair or a CFD, which reports no volume. Switch the symbol to a stock or a crypto pair.
- The chart shows the previous symbol with an amber notice — market data for the new instrument couldn't be loaded. Pick another listing, or try again shortly.
Related Guides
- Backtesting Python Strategies — Run the strategy and read the numbers, in seconds
- Export Python to Pine, MQL5 or NinjaScript — Take a finished strategy to the platform you trade on
- Quickstart — Build your first script with HorizonAI
- How to Talk to Horizon AI — Prompt tips for better scripts
- Visual Flow — See the logic of a script as a diagram