EA-49611 · Utility

Get_Last_Nth_Open_Trade

This EA scans all open positions and displays the details of the Nth trade from the sorted list on the chart. It supports optional filtering by magic number and symbol, sorts positions by ticket number in descending order, and prints trade information via the Comment() function.

Open the interactive view (equity curve, symbol switch)

Key facts

CategoryUtility
RiskSafe
Rating★★☆☆☆
TypeUtility tool
TimeframesM1, M5, M15, M30, H1, H4, D1
Indicators—
Authorhttps://tradingbotmaker.com/

Backtest results (H1, about 1 year)

Not backtested yet — this EA could not be converted automatically.

Strategy analysis

This EA is not a trading strategy but a position inquiry utility. Its core functionality iterates through all current open positions, filtering them based on user-configured magic number and symbol filters, and stores matching positions into a struct array. It then sorts all positions by ticket number in descending order using a bubble sort algorithm, and finally extracts the trade at the user-specified index (TRADE_INDEX) from the sorted array to display its details on the chart. The tool does not execute any opening, closing, or modification operations — it is purely for monitoring and displaying position status. The sorting algorithm uses a simple bubble sort which is inefficient but does not affect functional correctness. There is no entry or exit logic since no trades are placed.

Strengths

  • Supports flexible filtering by magic number and trading symbol
  • Uses structured storage for trade details, easy to extend and integrate
  • Displays position information intuitively on chart via Comment()

Weaknesses

  • Bubble sort is inefficient and performs poorly with many positions
  • Missing boundary checks — TRADE_INDEX out of range causes array out-of-bounds errors
  • Performs full scan and sort on every tick with no throttling, causing unnecessary resource consumption
  • MAGICNUMBER is not declared as an input variable, making it unmodifiable from the parameter panel

Possible improvements

  • Change MAGICNUMBER to an input variable so it can be configured from the parameter panel
  • Add boundary checks to prevent array out-of-bounds errors, and implement a timer or new bar check to reduce execution frequency

Risk assessment

Overall risk: Safe

  • Array out-of-bounds risk: TRADE_INDEX exceeding the filtered position count causes array access violation
  • Full scan on every tick may waste CPU resources under high-frequency market conditions

Evaluation scores

Code quality2.0
Strategy logic1.0
Risk management4.0
Robustness2.0
Innovation1.0
Documentation2.0
Overall2.0

Parameters

ParameterDefaultDescription
ENABLE_MAGIC_NUMBERfalseWhether to enable magic number filter
ENABLE_SYMBOL_FILTERfalseWhether to enable symbol filter
MAGICNUMBER1234Magic number for filtering
TRADE_INDEX2Closed trade index to query (from latest)

Similar Utility EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.