Fibonacci Retracement Trading Strategy Script
Pine Script strategy by Zer3192.
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 50 | Fibonacci cycle length |
| v_input_2 | 0.236 | Fibonacci levels1 |
| v_input_3 | 0.382 | Fibonacci levels2 |
| v_input_4 | 0.618 | Fibonacci levels3 |
Source Pine Script
/*backtest
start: 2022-10-27 00:00:00
end: 2023-11-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Fibonacci retracement trading strategy", overlay=true, initial_capital=10000)
// Parameters
length = input(50, title="Fibonacci cycle length")
fib1 = input(0.236, title="Fibonacci levels1")
fib2 = input(0.382, title="Fibonacci levels2")
fib3 = input(0.618, title="Fibonacci levels3")
// Calculate Fibonacci levels
highLevel = ta.highest(high, length)
lowLevel = ta.lowest(low, length)
range1 = highLevel - lowLevel
fibLevel1 = highLevel - range1 * fib1
fibLevel2 = highLevel - range1 * fib2
fibLevel3 = highLevel - range1 * fib3
// condition
longCondition = ta.crossover(close, fibLevel3)
shortCondition = ta.crossunder(close, fibLevel1)
// Place Order
strategy.entry("Buy", strategy.long, when=longCondition)
strategy.close("Buy", when=shortCondition)
// Chart Marker
plot(fibLevel1, title="Fib 0.236", color=color.red)
plot(fibLevel2, title="Fib 0.382", color=color.orange)
plot(fibLevel3, title="Fib 0.618", color=color.green)
Published by Zer3192 on the FMZ strategy square · last modified 2023-11-03. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Fibonacci-Retracement-Trading-Strategy-Script.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Fibonacci Timing PatternPine Script · Other · 4h
- ZigZag PA Strategy V41Pine Script · Other · 1h
- Comparison of Native Multithreaded JavaScript and WASM PerformanceJavaScript · Other
- Angle Attack Follow Line IndicatorPine Script · Other · 15m
- Bully SignalsPine Script · Other · 1h
- Customizable Backtest Start Time StrategyPine Script · Other · 2d