Loading…

Order At Fibonacci Level

The fib is already drawn over the swing; the plan is "buy the 61.8". Between that plan and a correct order ticket sit two traps this script exists to avoid. The first is trusting the drawing. The level lines of a fib object are user property - people add 78.6, delete 23.6, or type custom values into the levels tab, and a template can restyle them wholesale. A script that hunts for the drawn line labelled "61.8" finds whatever the object happens to contain today. This script reads only the two anchor points and computes the level price from them, using the platform's own convention: 0% sits at the second anchor (the end of the swing), 100% at the first. The log prints the object's whole configured level list next to the prices computed from the anchors, so any disagreement is visible before an order exists. The second is ambiguity about WHICH fib. Charts accumulate objects. Given a name, the script uses exactly that object and nothing else. Given no name, it takes the most recently drawn fib - and prints every candidate with its creation time and anchors, so the choice is auditable rather than silent. Ties (charts restored from templates can carry equal creation times) break towards the fib whose anchors reach the most recent bars. The order itself follows the geometry: you state the direction, and the type - stop or limit - is derived from the level's side of the market, overridable but never silently contradicted. The computed price is snapped to the broker's tick grid, checked against the minimum stop distance, and confirmed to you with the swing and percentage spelled out before anything is sent. A custom percentage below 5 is refused as the classic "0.618 typed instead of 61.8" slip. Notes and limitations - The script must run on the chart the fib is drawn on. Objects do not exist across charts. - The level price is computed once, at run time. Re-anchoring the fib afterwards moves nothing - the order does not follow the drawing. - Only OBJ_FIBO retracement objects are considered. Fib expansions, fans, arcs and time zones are different objects with different geometry and are deliberately not guessed at. - A level closer to the market than the broker's minimum stop distance is refused with both numbers printed. - The order is GTC: no expiry, survives restarts, until filled or deleted. - "Most recent" means most recently created on this chart. If in doubt, name the object explicitly - the log shows every candidate precisely so you can.

Script · MT5 · v1.0 · Free

About Order At Fibonacci Level

Order At Fibonacci Level is an expert advisor (trading robot) for MetaTrader 5. It places pending buy/sell stop or limit orders. It has 12 settings, such as Fibo name, Level and Custom percent. MQL source code included.

Files in the download: OrderAtFibLevel.ex5, OrderAtFibLevel.mq5, OrderAtFibLevel.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Fibo nameFibonacci object name (empty = most recent)
LevelFIB_61_8Level to place the order at
Custom percent78.6Custom level, percent (used when Custom)
DirectionDIR_BUYTrade direction
Pending modePENDING_AUTOPending order type
Lots0.10Volume, in lots
Stop loss pips0Stop loss distance, pips (0 = none)
Take profit pips0Take profit distance, pips (0 = none)
Magic0Magic number written on the order
Max retries5Attempts before giving up
Retry wait ms500Pause between attempts, milliseconds
Confirm firsttrueAsk for confirmation before placing

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Fibonacci · Pending Orders · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria