Learn Pine Script, MQL5 and trading risk
Guides, data studies, indicator scripts, error fixes and free calculators, grouped by what you are working on. Everything here is free to read and use.
Pine Script and TradingView
Write, fix and test TradingView indicators and strategies in Pine Script v6.
Guides
- Pine Script session and time filters: trade only during London or New York hours (v6)
Filter Pine Script v6 signals by session, time zone and weekday, handle daylight saving and the London/New York overlap, and close trades when the window ends.
- strategy.entry vs strategy.order in Pine Script v6: reversals, pyramiding, closing and position size
strategy.entry vs strategy.order, strategy.close and strategy.exit in Pine Script v6: automatic reversals, pyramiding, partial closes and risk-based quantity.
- How to convert Pine Script v5 to v6: every breaking change, with before and after code
Convert a Pine Script from v5 to v6: the editor's converter, every breaking change with before/after code, and the checks that catch silent result changes.
- How to build a multi-symbol screener in Pine Script v6 (with a table and alerts)
Build a Pine Script v6 screener that scans eight symbols from any chart: RSI, trend and your own setup in a table, non-repainting values and one alert for all.
- Can ChatGPT write Pine Script? What goes wrong and how to get code that works
ChatGPT and other chatbots can write Pine Script, but often in old versions, with invented functions or look-ahead bugs. How to spot and fix each problem.
- Pine Script strategy template (v6): risk-based sizing, ATR stop, take profit and filters
A reusable Pine Script v6 strategy template: risk-per-trade sizing, ATR stop, R-multiple target, date, session and daily filters. Swap in your own signal.
- How to backtest on TradingView: the Strategy Tester settings that change your results
Every TradingView Strategy Tester property that changes a backtest: order size, commission, slippage, margin, bar magnifier and fills, with the strategy() code.
- Pine Script EMA crossover strategy: a complete v6 example with stops and costs
Build an EMA crossover strategy in Pine Script v6 with a trend filter, ATR stop and target, commission and slippage, then test it without fooling yourself.
- Pine Script strategy.exit(): stop loss and take profit that behave as you expect
How strategy.exit() works in Pine Script v6: price or tick-based stops and targets, levels fixed at entry, break-even, trailing stops, partial take-profits.
- Pine Script alerts: alertcondition() vs alert(), messages, webhooks and frequency
alertcondition() or alert()? How Pine Script v6 alerts work, dynamic and webhook messages, strategy order alerts, and the frequency that stops false alerts.
- Multi-timeframe Pine Script with request.security(), without repainting
Use higher-timeframe data in Pine Script v6 with request.security(): the non-repainting pattern, tuples, timeframe checks, gaps and lower-timeframe limits.
- Pine Script repainting: how to spot it, test for it and fix it
Why some TradingView indicators repaint, the usual causes, how to test any script on replay and live charts, and the Pine Script v6 fix for each one.
- How to code RSI divergence in Pine Script v6 (without repainting)
Detect bullish and bearish RSI divergence in Pine Script v6 with confirmed pivots, draw and alert on it, and avoid the v6 detail that breaks many scripts.
- Pine Script v6 for beginners: the concepts that make everything click
A beginner's tour of Pine Script v6: how scripts run bar by bar, series and history, inputs, plots, strategies, what changed from v5, with working examples.
- How to add a Pine Script indicator to TradingView
Paste, save and add a Pine Script v6 indicator or strategy to your TradingView chart, then change its settings, create alerts and fix common compile errors.
Pine Script errors
- Undeclared identifier
- Mismatched input
- End of line without line continuation
- Syntax error at input
- No viable alternative at character
- Variable is already defined
- series int used but simple int expected
- hline(): series float used but input float expected
- series string used but const string expected
- Value with NA type cannot be assigned
- Return type of if/switch blocks not compatible
- Cannot assign a value of another type
- simple variable cannot accept a series value
- Cannot call operator + with a string and a number
- Cannot use plot in local scope
- Cannot modify global variable in function
- Should be called on each calculation for consistency
- Shadowing variable which exists in parent scope
- Could not find function 'study'
- Could not find function 'security'
- Could not find function or function reference
- No argument named transp
- No argument named when
- na() on a bool
- A bool can't be na
- if condition must be a bool
- Loop is too long
- Historical offset beyond the buffer limit (max_bars_back)
- Too many securities (request.* limit)
- Array index is out of bounds
- Inline inputs might not align
- Memory limits exceeded
Pine Script examples
- Buy and sell markers (plotshape)
- Labels and lines (label.new, line.new)
- Dashboard table (table.new)
- Background, fill and bar colors
- Moving average ribbon by slope
- Crossover and crossunder
- Pivot support and resistance
- Value since an event (valuewhen, barssince)
- Higher highs and lower lows
- barstate.isconfirmed (closed bars)
- Daily open, previous day and time
- ATR trailing stop (strategy)
- Position sizing in a strategy
- var vs varip
- Arrays (push, shift, avg)
- for and while loops
- Functions and methods
- Inputs and the settings tab
- max_bars_back and history
- Libraries (export, import)
MetaTrader 5 and MQL5
Expert Advisors in MQL5: install, size, trail, guard and convert them.
Guides
- Martingale EAs on MT5: the math of the losing streak, and the guardrails if you run one
Why martingale EAs win often and still blow up: lot sizes, the odds of a long losing streak, the unchanged expectancy, and an MQL5 EA with hard caps.
- MT5 Strategy Tester modelling modes: every tick, real ticks, 1-minute OHLC, and why backtests differ from live
What each MetaTrader 5 tick mode simulates, how spread and delays enter the test, and an EA pattern that gives the same signals in every mode. With MQL5 code.
- How to convert MQL4 to MQL5: moving an Expert Advisor from MT4 to MT5
Port an MT4 Expert Advisor to MQL5: orders vs positions, indicator handles, Bid/Ask and OrderSend vs CTrade, with a fully converted EA and the pitfalls to test.
- MQL5 OrderSend errors explained: 10016 invalid stops, 10030 filling mode, 10019 no money and more
Why an MT5 Expert Advisor's order fails: trade server return codes 10004 to 10046 and error 4756, with MQL5 checks for stops, filling mode, volume and margin.
- MT5 EA prop firm rules: coding a daily loss limit and drawdown guard in MQL5
Make an MT5 Expert Advisor respect prop-firm-style rules: a daily loss guard that survives restarts, an overall loss floor and a trade cap, with MQL5 code.
- MQL5 lot size from risk percent: a sizing function that works on any symbol
Calculate MT5 lot size from a risk percent in MQL5 with OrderCalcProfit: round to the volume step, include commission, check margin, avoid oversized trades.
- MQL5 trailing stop: points, ATR and break-even code for MT5 Expert Advisors
Add a trailing stop to an MT5 Expert Advisor in MQL5: fixed-point and ATR trailing, break-even, broker stop and freeze levels, only the EA's own positions.
- MQL5 magic numbers explained: keep each Expert Advisor's trades separate
What a magic number is in MetaTrader 5, how to set and filter it in MQL5, how to pick unique numbers, and the netting-account case where it can't help.
- How to convert Pine Script to MQL5: a practical guide for TradingView traders
Port a TradingView Pine Script strategy to an MT5 Expert Advisor: how bars, series, indicators and orders map to MQL5, with a worked EMA crossover example.
- The MQL5 Expert Advisor risk checklist: 12 checks before you go live
A pre-flight checklist for MetaTrader 5 EAs: risk-based lot sizing, broker limits, spread and session filters, daily loss guards and safe orders, in MQL5.
- How to install an Expert Advisor on MetaTrader 5 (step by step)
Copy, compile and attach an MQL5 Expert Advisor in MT5: the right folder, MetaEditor, Algo Trading, inputs, the Strategy Tester and fixes for common errors.
MQL5 errors
- 10016 Invalid stops
- 10030 Unsupported filling mode
- 10019 Not enough money
- 10014 Invalid volume
- 10018 Market closed
- 10027 Autotrading disabled
- 10004 Requote
- 10015 Invalid price
- 10025 No changes
- 10029 Frozen
- 10017 Trade disabled
- 4756 Trade request sending failed
- 4752 Trading by EAs prohibited
- 4806 Requested data not found
- 4802 Indicator cannot be created
- Array out of range
- Zero divide
- Undeclared identifier
- Wrong parameters count
- Implicit conversion from number to string
- Possible loss of data due to type conversion
- Return value of OrderSend should be checked
- Not all control paths return a value
- Unexpected end of program
- Cannot convert enum
MQL5 examples
- Market buy or sell with CTrade
- Close all positions
- Pending orders with expiry
- Move stop to break-even
- Partial close
- Normalize price and lot size
- Detect a new bar
- Read iMA and iRSI values
- Read a custom indicator (iCustom)
- Moving average crossover EA
- Session and time filter
- Limit trades per day
- OnTimer
- Draw lines, arrows and text
- On-chart dashboard
- Write trades to CSV
- Alerts and push notifications
- WebRequest webhook (POST JSON)
- Custom optimization criterion (OnTester)
Pine Script to MQL5
- Pine Script to MQL5
- Worked port: EMA cross with ATR stop
- ta.crossover and ta.crossunder
- request.security on a higher timeframe
- strategy.entry to CTrade
- ta.sma, ta.ema, ta.rsi and ta.atr
- barstate.isconfirmed and new bars
- var and varip
- plot, fill and plotshape
- alertcondition and alert
- ta.pivothigh and ta.pivotlow
- strategy.exit stop loss and take profit
Python and crypto bots
Crypto bots in Python with ccxt, and the numbers behind leveraged crypto trading.
Guides
- How to send TradingView alerts to a webhook: JSON messages, placeholders and a Python receiver
TradingView webhook alerts step by step: the requirements, a JSON message with the right placeholders, Pine alert() code and a tested Python receiver.
- How to build a Python crypto trading bot with ccxt: data, signals, orders and a testnet
A complete Python bot on ccxt: closed Binance candles, one signal function for backtest and live, risk-based sizing, exchange limits and testnet orders.
- How to convert Pine Script to Python: indicators, signals and a backtest loop in pandas
Convert Pine Script to Python: how series, ta.* functions and request.security map to pandas, a backtest loop that fills like Pine, and a parity check.
Backtesting and data studies
How to test a strategy honestly, and what our own tests on real data found.
Guides
- We backtested 11 classic indicators at their default settings on crypto. 32 of 154 runs beat buy and hold.
RSI, MACD, EMA, Bollinger, Supertrend and 6 more at default settings on 7 coins, 2020 to 2026, fees included: 32 of 154 runs beat buy and hold.
- Does the 200-day moving average protect you in crypto? We tested it on BTC, ETH and SOL
Hold BTC, ETH or SOL only above the 200-day average, fees included, since 2018. It dodged most of 2022 but cut the worst drawdown far less than you'd think.
- Grid trading bot backtest: a fresh Bitcoin grid every month for 58 months
We ran a spot grid bot on Bitcoin every month from 2022 to 2026 on 1-minute Binance data: more winning months than holding, but a lower average.
- Walk-forward analysis for retail traders: out-of-sample testing on a real Bitcoin example
How walk-forward testing works, why in-sample results are always too good, and a real run on 8 years of Bitcoin data: in-sample Sharpe 1.44, out-of-sample 0.22.
- Crypto futures position sizing: risk per trade, leverage and the liquidation price (isolated vs cross)
Size a crypto futures trade from your stop, then check liquidation sits beyond it: isolated and cross margin formulas, worked BTC examples and Python code.
- We backtested 2,160 crypto scalping strategies on 1-minute data. None of them beat the fees.
2,160 scalping setups, three years of Binance 1-minute data for BTC, ETH and SOL, honest fills and retail fees. Nothing survived. The numbers, and why.
- Can leverage make 10% a day? We simulated 240 setups on three years of crypto data
240 leveraged setups on BTC, ETH and SOL futures, x5 to x100, with fees, funding and liquidations. The goal was +10% a day. Here's what happened.
- 8 backtesting mistakes that make a strategy look better than it is
Look-ahead bias, repainting, overfitting, missing costs and unrealistic fills: how each inflates a backtest and how to spot and fix it in TradingView and MT5.
Risk, sizing and prop firms
Position size, drawdown and funded-challenge rules, with the calculators to apply them.
Guides
- Crypto funding rates explained: what holding a BTC, ETH or SOL perpetual cost over the past year
How perpetual funding works, and what it really cost: all 1,095 Binance funding settlements for BTC, ETH and SOL from Nov 2025 to Oct 2026, month by month.
- Prop firm challenge rules explained: daily loss, drawdown and the fine print
Prop firm challenge rules explained: daily loss, static and trailing drawdown, minimum days and EA rules, and how to size trades so one bad day isn't the end.
- Position sizing and the 1% rule: how much to risk per trade
The 1% rule turned into position sizes for forex, gold, indices, crypto, stocks and futures, with costs, losing-streak odds and when to risk less.
Chart analysis and strategy ideas
Read a chart, describe a strategy so AI codes what you mean, and the levels traders use.
Guides
- What is a good profit factor? What the number means and how many trades it needs
Profit factor explained with real math: its link to win rate and expectancy, how far luck moves it, what costs do, and code for TradingView and MT5.
- What AI chart analysis can (and can't) do for your trading
An honest look at screenshot-based AI chart analysis: what a model reads well, where it goes wrong and how to use it as a second opinion rather than a signal.
- Smart money concepts explained without the hype
Market structure, BOS and CHoCH, liquidity sweeps, order blocks, fair value gaps and premium/discount, defined plainly and turned into rules you can test.
- How to describe a trading strategy to AI so the code does what you mean
A template for strategy prompts that produce correct Pine Script and MQL5: precise entries and exits, risk rules, filters, inputs and the words to avoid.
Comparisons
How Edgoro compares with other AI Pine Script and MT5 tools, with dated sources and where the others do better.
Build it with Edgoro
When you would rather describe the strategy than write the code.
Pine Script generator
Describe your setup in plain English and get Pine Script v6 for TradingView: indicators, strategies and alerts, with install steps. $29/month or $49 once.
MT5 EA generator
Turn your trading rules into an MQL5 Expert Advisor for MetaTrader 5: risk inputs built in, compile-checked in MetaEditor, errors fixed automatically.
Crypto trading bot generator
Describe a strategy and get a Python crypto trading bot built on ccxt for Binance, Bybit, OKX or Kraken, with paper mode on by default and a syntax check.
AI chart analysis
Upload a chart screenshot and get an AI chart analysis: market structure, key levels, bullish and bearish scenarios, a risk plan and a confidence level.
Backtest Lab
Backtest Lab tests your trading strategy on up to 3 years of crypto candles, with fees, slippage, an out-of-sample check and a plain-English verdict.
Copilot
Edgoro Copilot is an AI trading assistant: live prices and technicals, news, the economic calendar, price alerts on Telegram and your journal in one chat.
Prop firm tools
The Prop Firm Pack builds your challenge rules into every bot: daily loss, drawdown and trade-count guards, plus 20 templates. Free prop firm calculator too.
En français : Générateur Pine Script · Générateur de robot MT5 · Générateur de bot de trading crypto